md2html.py 27 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211
  1. import re, os
  2. import sys
  3. import markdown
  4. import codecs
  5. try:
  6. from importlib import reload
  7. print("running with importlib")
  8. reload(sys)
  9. except ImportError:
  10. print("Failed to import importlib")
  11. reload(sys)
  12. sys.setdefaultencoding('utf-8')
  13. # python mdtohtml.py filename
  14. pre_content = '''
  15. <!doctype html>
  16. <html style='font-size:14px !important'>
  17. <head>
  18. <meta charset='UTF-8'>
  19. <meta name='viewport' content='width=device-width initial-scale=1'>
  20. <title>ChangeLog</title>
  21. <style type='text/css'>
  22. html {
  23. overflow-x: initial !important;
  24. }
  25. :root {
  26. --bg-color: #ffffff;
  27. --text-color: #333333;
  28. --select-text-bg-color: #B5D6FC;
  29. --select-text-font-color: auto;
  30. --monospace: "Lucida Console",Consolas,"Courier",monospace;
  31. }
  32. html {
  33. font-size: 14px;
  34. background-color: var(--bg-color);
  35. color: var(--text-color);
  36. font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  37. -webkit-font-smoothing: antialiased;
  38. }
  39. body {
  40. margin: 0px;
  41. padding: 0px;
  42. height: auto;
  43. bottom: 0px;
  44. top: 0px;
  45. left: 0px;
  46. right: 0px;
  47. font-size: 1rem;
  48. line-height: 1.42857;
  49. overflow-x: hidden;
  50. background: inherit;
  51. tab-size: 4;
  52. }
  53. iframe {
  54. margin: auto;
  55. }
  56. a.url {
  57. word-break: break-all;
  58. }
  59. a:active, a:hover {
  60. outline: 0px;
  61. }
  62. .in-text-selection, ::selection {
  63. text-shadow: none;
  64. background: var(--select-text-bg-color);
  65. color: var(--select-text-font-color);
  66. }
  67. #write {
  68. margin: 0px auto;
  69. height: auto;
  70. width: inherit;
  71. word-break: normal;
  72. overflow-wrap: break-word;
  73. position: relative;
  74. white-space: normal;
  75. overflow-x: visible;
  76. padding-top: 40px;
  77. }
  78. #write.first-line-indent p {
  79. text-indent: 2em;
  80. }
  81. #write.first-line-indent li p, #write.first-line-indent p * {
  82. text-indent: 0px;
  83. }
  84. #write.first-line-indent li {
  85. margin-left: 2em;
  86. }
  87. .for-image #write {
  88. padding-left: 8px;
  89. padding-right: 8px;
  90. }
  91. body.typora-export {
  92. padding-left: 30px;
  93. padding-right: 30px;
  94. }
  95. .typora-export .footnote-line, .typora-export li, .typora-export p {
  96. white-space: pre-wrap;
  97. }
  98. @media screen and (max-width: 500px) {
  99. body.typora-export {
  100. padding-left: 0px;
  101. padding-right: 0px;
  102. }
  103. #write {
  104. padding-left: 20px;
  105. padding-right: 20px;
  106. }
  107. .CodeMirror-sizer {
  108. margin-left: 0px !important;
  109. }
  110. .CodeMirror-gutters {
  111. display: none !important;
  112. }
  113. }
  114. #write li > figure:last-child {
  115. margin-bottom: 0.5rem;
  116. }
  117. #write ol, #write ul {
  118. position: relative;
  119. }
  120. img {
  121. max-width: 100%;
  122. vertical-align: middle;
  123. }
  124. button, input, select, textarea {
  125. color: inherit;
  126. font: inherit;
  127. }
  128. input[type="checkbox"], input[type="radio"] {
  129. line-height: normal;
  130. padding: 0px;
  131. }
  132. *, ::after, ::before {
  133. box-sizing: border-box;
  134. }
  135. #write h1, #write h2, #write h3, #write h4, #write h5, #write h6, #write p, #write pre {
  136. width: inherit;
  137. }
  138. #write h1, #write h2, #write h3, #write h4, #write h5, #write h6, #write p {
  139. position: relative;
  140. }
  141. p {
  142. line-height: inherit;
  143. }
  144. h1, h2, h3, h4, h5, h6 {
  145. break-after: avoid-page;
  146. break-inside: avoid;
  147. orphans: 2;
  148. }
  149. p {
  150. orphans: 4;
  151. }
  152. h1 {
  153. font-size: 2rem;
  154. }
  155. h2 {
  156. font-size: 1.8rem;
  157. }
  158. h3 {
  159. font-size: 1.6rem;
  160. }
  161. h4 {
  162. font-size: 1.4rem;
  163. }
  164. h5 {
  165. font-size: 1.2rem;
  166. }
  167. h6 {
  168. font-size: 1rem;
  169. }
  170. .md-math-block, .md-rawblock, h1, h2, h3, h4, h5, h6, p {
  171. margin-top: 1rem;
  172. margin-bottom: 1rem;
  173. }
  174. .hidden {
  175. display: none;
  176. }
  177. .md-blockmeta {
  178. color: rgb(204, 204, 204);
  179. font-weight: 700;
  180. font-style: italic;
  181. }
  182. a {
  183. cursor: pointer;
  184. }
  185. sup.md-footnote {
  186. padding: 2px 4px;
  187. background-color: rgba(238, 238, 238, 0.7);
  188. color: rgb(85, 85, 85);
  189. border-radius: 4px;
  190. cursor: pointer;
  191. }
  192. sup.md-footnote a, sup.md-footnote a:hover {
  193. color: inherit;
  194. text-transform: inherit;
  195. text-decoration: inherit;
  196. }
  197. #write input[type="checkbox"] {
  198. cursor: pointer;
  199. width: inherit;
  200. height: inherit;
  201. }
  202. figure {
  203. overflow-x: auto;
  204. margin: 1.2em 0px;
  205. max-width: calc(100% + 16px);
  206. padding: 0px;
  207. }
  208. figure > table {
  209. margin: 0px !important;
  210. }
  211. tr {
  212. break-inside: avoid;
  213. break-after: auto;
  214. }
  215. thead {
  216. display: table-header-group;
  217. }
  218. table {
  219. border-collapse: collapse;
  220. border-spacing: 0px;
  221. width: 100%;
  222. overflow: auto;
  223. break-inside: auto;
  224. text-align: left;
  225. }
  226. table.md-table td {
  227. min-width: 32px;
  228. }
  229. .CodeMirror-gutters {
  230. border-right: 0px;
  231. background-color: inherit;
  232. }
  233. .CodeMirror-linenumber {
  234. user-select: none;
  235. }
  236. .CodeMirror {
  237. text-align: left;
  238. }
  239. .CodeMirror-placeholder {
  240. opacity: 0.3;
  241. }
  242. .CodeMirror pre {
  243. padding: 0px 4px;
  244. }
  245. .CodeMirror-lines {
  246. padding: 0px;
  247. }
  248. div.hr:focus {
  249. cursor: none;
  250. }
  251. #write pre {
  252. white-space: pre-wrap;
  253. }
  254. #write.fences-no-line-wrapping pre {
  255. white-space: pre;
  256. }
  257. #write pre.ty-contain-cm {
  258. white-space: normal;
  259. }
  260. .CodeMirror-gutters {
  261. margin-right: 4px;
  262. }
  263. .md-fences {
  264. font-size: 0.9rem;
  265. display: block;
  266. break-inside: avoid;
  267. text-align: left;
  268. overflow: visible;
  269. white-space: pre;
  270. background: inherit;
  271. position: relative !important;
  272. }
  273. .md-diagram-panel {
  274. width: 100%;
  275. margin-top: 10px;
  276. text-align: center;
  277. padding-top: 0px;
  278. padding-bottom: 8px;
  279. overflow-x: auto;
  280. }
  281. #write .md-fences.mock-cm {
  282. white-space: pre-wrap;
  283. }
  284. .md-fences.md-fences-with-lineno {
  285. padding-left: 0px;
  286. }
  287. #write.fences-no-line-wrapping .md-fences.mock-cm {
  288. white-space: pre;
  289. overflow-x: auto;
  290. }
  291. .md-fences.mock-cm.md-fences-with-lineno {
  292. padding-left: 8px;
  293. }
  294. .CodeMirror-line, twitterwidget {
  295. break-inside: avoid;
  296. }
  297. .footnotes {
  298. opacity: 0.8;
  299. font-size: 0.9rem;
  300. margin-top: 1em;
  301. margin-bottom: 1em;
  302. }
  303. .footnotes + .footnotes {
  304. margin-top: 0px;
  305. }
  306. .md-reset {
  307. margin: 0px;
  308. padding: 0px;
  309. border: 0px;
  310. outline: 0px;
  311. vertical-align: top;
  312. background: 0px 0px;
  313. text-decoration: none;
  314. text-shadow: none;
  315. float: none;
  316. position: static;
  317. width: auto;
  318. height: auto;
  319. white-space: nowrap;
  320. cursor: inherit;
  321. -webkit-tap-highlight-color: transparent;
  322. line-height: normal;
  323. font-weight: 400;
  324. text-align: left;
  325. box-sizing: content-box;
  326. direction: ltr;
  327. }
  328. li div {
  329. padding-top: 0px;
  330. }
  331. blockquote {
  332. margin: 1rem 0px;
  333. }
  334. li .mathjax-block, li p {
  335. margin: 0.5rem 0px;
  336. }
  337. li {
  338. margin: 0px;
  339. position: relative;
  340. }
  341. blockquote > :last-child {
  342. margin-bottom: 0px;
  343. }
  344. blockquote > :first-child, li > :first-child {
  345. margin-top: 0px;
  346. }
  347. .footnotes-area {
  348. color: rgb(136, 136, 136);
  349. margin-top: 0.714rem;
  350. padding-bottom: 0.143rem;
  351. white-space: normal;
  352. }
  353. #write .footnote-line {
  354. white-space: pre-wrap;
  355. }
  356. @media print {
  357. body, html {
  358. border: 1px solid transparent;
  359. height: 99%;
  360. break-after: avoid;
  361. break-before: avoid;
  362. }
  363. #write {
  364. margin-top: 0px;
  365. padding-top: 0px;
  366. border-color: transparent !important;
  367. }
  368. .typora-export * {
  369. -webkit-print-color-adjust: exact;
  370. }
  371. html.blink-to-pdf {
  372. font-size: 13px;
  373. }
  374. .typora-export #write {
  375. padding-left: 32px;
  376. padding-right: 32px;
  377. padding-bottom: 0px;
  378. break-after: avoid;
  379. }
  380. .typora-export #write::after {
  381. height: 0px;
  382. }
  383. }
  384. .footnote-line {
  385. margin-top: 0.714em;
  386. font-size: 0.7em;
  387. }
  388. a img, img a {
  389. cursor: pointer;
  390. }
  391. pre.md-meta-block {
  392. font-size: 0.8rem;
  393. min-height: 0.8rem;
  394. white-space: pre-wrap;
  395. background: rgb(204, 204, 204);
  396. display: block;
  397. overflow-x: hidden;
  398. }
  399. p > .md-image:only-child:not(.md-img-error) img, p > img:only-child {
  400. display: block;
  401. margin: auto;
  402. }
  403. p > .md-image:only-child {
  404. display: inline-block;
  405. width: 100%;
  406. }
  407. #write .MathJax_Display {
  408. margin: 0.8em 0px 0px;
  409. }
  410. .md-math-block {
  411. width: 100%;
  412. }
  413. .md-math-block:not(:empty)::after {
  414. display: none;
  415. }
  416. [contenteditable="true"]:active, [contenteditable="true"]:focus {
  417. outline: 0px;
  418. box-shadow: none;
  419. }
  420. .md-task-list-item {
  421. position: relative;
  422. list-style-type: none;
  423. }
  424. .task-list-item.md-task-list-item {
  425. padding-left: 0px;
  426. }
  427. .md-task-list-item > input {
  428. position: absolute;
  429. top: 0px;
  430. left: 0px;
  431. margin-left: -1.2em;
  432. margin-top: calc(1em - 10px);
  433. border: none;
  434. }
  435. .math {
  436. font-size: 1rem;
  437. }
  438. .md-toc {
  439. min-height: 3.58rem;
  440. position: relative;
  441. font-size: 0.9rem;
  442. border-radius: 10px;
  443. }
  444. .md-toc-content {
  445. position: relative;
  446. margin-left: 0px;
  447. }
  448. .md-toc-content::after, .md-toc::after {
  449. display: none;
  450. }
  451. .md-toc-item {
  452. display: block;
  453. color: rgb(65, 131, 196);
  454. }
  455. .md-toc-item a {
  456. text-decoration: none;
  457. }
  458. .md-toc-inner:hover {
  459. text-decoration: underline;
  460. }
  461. .md-toc-inner {
  462. display: inline-block;
  463. cursor: pointer;
  464. }
  465. .md-toc-h1 .md-toc-inner {
  466. margin-left: 0px;
  467. font-weight: 700;
  468. }
  469. .md-toc-h2 .md-toc-inner {
  470. margin-left: 2em;
  471. }
  472. .md-toc-h3 .md-toc-inner {
  473. margin-left: 4em;
  474. }
  475. .md-toc-h4 .md-toc-inner {
  476. margin-left: 6em;
  477. }
  478. .md-toc-h5 .md-toc-inner {
  479. margin-left: 8em;
  480. }
  481. .md-toc-h6 .md-toc-inner {
  482. margin-left: 10em;
  483. }
  484. @media screen and (max-width: 48em) {
  485. .md-toc-h3 .md-toc-inner {
  486. margin-left: 3.5em;
  487. }
  488. .md-toc-h4 .md-toc-inner {
  489. margin-left: 5em;
  490. }
  491. .md-toc-h5 .md-toc-inner {
  492. margin-left: 6.5em;
  493. }
  494. .md-toc-h6 .md-toc-inner {
  495. margin-left: 8em;
  496. }
  497. }
  498. a.md-toc-inner {
  499. font-size: inherit;
  500. font-style: inherit;
  501. font-weight: inherit;
  502. line-height: inherit;
  503. }
  504. .footnote-line a:not(.reversefootnote) {
  505. color: inherit;
  506. }
  507. .md-attr {
  508. display: none;
  509. }
  510. .md-fn-count::after {
  511. content: ".";
  512. }
  513. code, pre, samp, tt {
  514. font-family: var(--monospace);
  515. }
  516. kbd {
  517. margin: 0px 0.1em;
  518. padding: 0.1em 0.6em;
  519. font-size: 0.8em;
  520. color: rgb(36, 39, 41);
  521. background: rgb(255, 255, 255);
  522. border: 1px solid rgb(173, 179, 185);
  523. border-radius: 3px;
  524. box-shadow: rgba(12, 13, 14, 0.2) 0px 1px 0px, rgb(255, 255, 255) 0px 0px 0px 2px inset;
  525. white-space: nowrap;
  526. vertical-align: middle;
  527. }
  528. .md-comment {
  529. color: rgb(162, 127, 3);
  530. opacity: 0.8;
  531. font-family: var(--monospace);
  532. }
  533. code {
  534. text-align: left;
  535. vertical-align: initial;
  536. }
  537. a.md-print-anchor {
  538. white-space: pre !important;
  539. border-width: initial !important;
  540. border-style: none !important;
  541. border-color: initial !important;
  542. display: inline-block !important;
  543. position: absolute !important;
  544. width: 1px !important;
  545. right: 0px !important;
  546. outline: 0px !important;
  547. background: 0px 0px !important;
  548. text-decoration: initial !important;
  549. text-shadow: initial !important;
  550. }
  551. .md-inline-math .MathJax_SVG .noError {
  552. display: none !important;
  553. }
  554. .html-for-mac .inline-math-svg .MathJax_SVG {
  555. vertical-align: 0.2px;
  556. }
  557. .md-math-block .MathJax_SVG_Display {
  558. text-align: center;
  559. margin: 0px;
  560. position: relative;
  561. text-indent: 0px;
  562. max-width: none;
  563. max-height: none;
  564. min-height: 0px;
  565. min-width: 100%;
  566. width: auto;
  567. overflow-y: hidden;
  568. display: block !important;
  569. }
  570. .MathJax_SVG_Display, .md-inline-math .MathJax_SVG_Display {
  571. width: auto;
  572. margin: inherit;
  573. display: inline-block !important;
  574. }
  575. .MathJax_SVG .MJX-monospace {
  576. font-family: var(--monospace);
  577. }
  578. .MathJax_SVG .MJX-sans-serif {
  579. font-family: sans-serif;
  580. }
  581. .MathJax_SVG {
  582. display: inline;
  583. font-style: normal;
  584. font-weight: 400;
  585. line-height: normal;
  586. zoom: 90%;
  587. text-indent: 0px;
  588. text-align: left;
  589. text-transform: none;
  590. letter-spacing: normal;
  591. word-spacing: normal;
  592. overflow-wrap: normal;
  593. white-space: nowrap;
  594. float: none;
  595. direction: ltr;
  596. max-width: none;
  597. max-height: none;
  598. min-width: 0px;
  599. min-height: 0px;
  600. border: 0px;
  601. padding: 0px;
  602. margin: 0px;
  603. }
  604. .MathJax_SVG * {
  605. transition: none 0s ease 0s;
  606. }
  607. .MathJax_SVG_Display svg {
  608. vertical-align: middle !important;
  609. margin-bottom: 0px !important;
  610. margin-top: 0px !important;
  611. }
  612. .os-windows.monocolor-emoji .md-emoji {
  613. font-family: "Segoe UI Symbol", sans-serif;
  614. }
  615. .md-diagram-panel > svg {
  616. max-width: 100%;
  617. }
  618. [lang="mermaid"] svg, [lang="flow"] svg {
  619. max-width: 100%;
  620. height: auto;
  621. }
  622. [lang="mermaid"] .node text {
  623. font-size: 1rem;
  624. }
  625. table tr th {
  626. border-bottom: 0px;
  627. }
  628. video {
  629. max-width: 100%;
  630. display: block;
  631. margin: 0px auto;
  632. }
  633. iframe {
  634. max-width: 100%;
  635. width: 100%;
  636. border: none;
  637. }
  638. .highlight td, .highlight tr {
  639. border: 0px;
  640. }
  641. svg[id^="mermaidChart"] {
  642. line-height: 1em;
  643. }
  644. mark {
  645. background: rgb(255, 255, 0);
  646. color: rgb(0, 0, 0);
  647. }
  648. .md-html-inline .md-plain, .md-html-inline strong, mark .md-inline-math, mark strong {
  649. color: inherit;
  650. }
  651. mark .md-meta {
  652. color: rgb(0, 0, 0);
  653. opacity: 0.3 !important;
  654. }
  655. :root {
  656. --side-bar-bg-color: #fafafa;
  657. --control-text-color: #777;
  658. }
  659. @include-when-export url(https://fonts.loli.net/css?family=Open+Sans:400italic,700italic,700,400&subset=latin,latin-ext);
  660. html {
  661. font-size: 16px;
  662. }
  663. body {
  664. font-family: "Open Sans","Clear Sans","Helvetica Neue",Helvetica,Arial,sans-serif;
  665. color: rgb(51, 51, 51);
  666. line-height: 1.6;
  667. }
  668. #write {
  669. max-width: 860px;
  670. margin: 0 auto;
  671. padding: 30px;
  672. padding-bottom: 100px;
  673. }
  674. #write > ul:first-child,
  675. #write > ol:first-child {
  676. margin-top: 30px;
  677. }
  678. a {
  679. color: #4183C4;
  680. }
  681. h1,
  682. h2,
  683. h3,
  684. h4,
  685. h5,
  686. h6 {
  687. position: relative;
  688. margin-top: 1rem;
  689. margin-bottom: 1rem;
  690. font-weight: bold;
  691. line-height: 1.4;
  692. cursor: text;
  693. }
  694. h1:hover a.anchor,
  695. h2:hover a.anchor,
  696. h3:hover a.anchor,
  697. h4:hover a.anchor,
  698. h5:hover a.anchor,
  699. h6:hover a.anchor {
  700. text-decoration: none;
  701. }
  702. h1 tt,
  703. h1 code {
  704. font-size: inherit;
  705. }
  706. h2 tt,
  707. h2 code {
  708. font-size: inherit;
  709. }
  710. h3 tt,
  711. h3 code {
  712. font-size: inherit;
  713. }
  714. h4 tt,
  715. h4 code {
  716. font-size: inherit;
  717. }
  718. h5 tt,
  719. h5 code {
  720. font-size: inherit;
  721. }
  722. h6 tt,
  723. h6 code {
  724. font-size: inherit;
  725. }
  726. h1 {
  727. padding-bottom: .3em;
  728. font-size: 2.25em;
  729. line-height: 1.2;
  730. border-bottom: 1px solid #eee;
  731. }
  732. h2 {
  733. padding-bottom: .3em;
  734. font-size: 1.75em;
  735. line-height: 1.225;
  736. border-bottom: 1px solid #eee;
  737. }
  738. h3 {
  739. font-size: 1.5em;
  740. line-height: 1.43;
  741. }
  742. h4 {
  743. font-size: 1.25em;
  744. }
  745. h5 {
  746. font-size: 1em;
  747. }
  748. h6 {
  749. font-size: 1em;
  750. color: #777;
  751. }
  752. p,
  753. blockquote,
  754. ul,
  755. ol,
  756. dl,
  757. table {
  758. margin: 0.8em 0;
  759. }
  760. li > ol,
  761. li > ul {
  762. margin: 0 0;
  763. }
  764. hr {
  765. height: 2px;
  766. padding: 0;
  767. margin: 16px 0;
  768. background-color: #e7e7e7;
  769. border: 0 none;
  770. overflow: hidden;
  771. box-sizing: content-box;
  772. }
  773. li p.first {
  774. display: inline-block;
  775. }
  776. ul,
  777. ol {
  778. padding-left: 30px;
  779. }
  780. ul:first-child,
  781. ol:first-child {
  782. margin-top: 0;
  783. }
  784. ul:last-child,
  785. ol:last-child {
  786. margin-bottom: 0;
  787. }
  788. blockquote {
  789. border-left: 4px solid #dfe2e5;
  790. padding: 0 15px;
  791. color: #777777;
  792. }
  793. blockquote blockquote {
  794. padding-right: 0;
  795. }
  796. table {
  797. padding: 0;
  798. word-break: initial;
  799. }
  800. table tr {
  801. border-top: 1px solid #dfe2e5;
  802. margin: 0;
  803. padding: 0;
  804. }
  805. table tr:nth-child(2n),
  806. thead {
  807. background-color: #f8f8f8;
  808. }
  809. table tr th {
  810. font-weight: bold;
  811. border: 1px solid #dfe2e5;
  812. border-bottom: 0;
  813. margin: 0;
  814. padding: 6px 13px;
  815. }
  816. table tr td {
  817. border: 1px solid #dfe2e5;
  818. margin: 0;
  819. padding: 6px 13px;
  820. }
  821. table tr th:first-child,
  822. table tr td:first-child {
  823. margin-top: 0;
  824. }
  825. table tr th:last-child,
  826. table tr td:last-child {
  827. margin-bottom: 0;
  828. }
  829. .CodeMirror-lines {
  830. padding-left: 4px;
  831. }
  832. .code-tooltip {
  833. box-shadow: 0 1px 1px 0 rgba(0,28,36,.3);
  834. border-top: 1px solid #eef2f2;
  835. }
  836. .md-fences,
  837. code,
  838. tt {
  839. border: 1px solid #e7eaed;
  840. background-color: #f8f8f8;
  841. border-radius: 3px;
  842. padding: 0;
  843. padding: 2px 4px 0px 4px;
  844. font-size: 0.9em;
  845. }
  846. code {
  847. background-color: #f3f4f4;
  848. padding: 0 2px 0 2px;
  849. }
  850. .md-fences {
  851. margin-bottom: 15px;
  852. margin-top: 15px;
  853. padding-top: 8px;
  854. padding-bottom: 6px;
  855. }
  856. .md-task-list-item > input {
  857. margin-left: -1.3em;
  858. }
  859. @media print {
  860. html {
  861. font-size: 13px;
  862. }
  863. table,
  864. pre {
  865. page-break-inside: avoid;
  866. }
  867. pre {
  868. word-wrap: break-word;
  869. }
  870. }
  871. .md-fences {
  872. background-color: #f8f8f8;
  873. }
  874. #write pre.md-meta-block {
  875. padding: 1rem;
  876. font-size: 85%;
  877. line-height: 1.45;
  878. background-color: #f7f7f7;
  879. border: 0;
  880. border-radius: 3px;
  881. color: #777777;
  882. margin-top: 0 !important;
  883. }
  884. .mathjax-block > .code-tooltip {
  885. bottom: .375rem;
  886. }
  887. .md-mathjax-midline {
  888. background: #fafafa;
  889. }
  890. #write > h3.md-focus:before {
  891. left: -1.5625rem;
  892. top: .375rem;
  893. }
  894. #write > h4.md-focus:before {
  895. left: -1.5625rem;
  896. top: .285714286rem;
  897. }
  898. #write > h5.md-focus:before {
  899. left: -1.5625rem;
  900. top: .285714286rem;
  901. }
  902. #write > h6.md-focus:before {
  903. left: -1.5625rem;
  904. top: .285714286rem;
  905. }
  906. .md-image > .md-meta {
  907. /*border: 1px solid #ddd;*/
  908. border-radius: 3px;
  909. padding: 2px 0px 0px 4px;
  910. font-size: 0.9em;
  911. color: inherit;
  912. }
  913. .md-tag {
  914. color: #a7a7a7;
  915. opacity: 1;
  916. }
  917. .md-toc {
  918. margin-top: 20px;
  919. padding-bottom: 20px;
  920. }
  921. .sidebar-tabs {
  922. border-bottom: none;
  923. }
  924. #typora-quick-open {
  925. border: 1px solid #ddd;
  926. background-color: #f8f8f8;
  927. }
  928. #typora-quick-open-item {
  929. background-color: #FAFAFA;
  930. border-color: #FEFEFE #e5e5e5 #e5e5e5 #eee;
  931. border-style: solid;
  932. border-width: 1px;
  933. }
  934. /** focus mode */
  935. .on-focus-mode blockquote {
  936. border-left-color: rgba(85, 85, 85, 0.12);
  937. }
  938. header, .context-menu, .megamenu-content, footer {
  939. font-family: "Segoe UI", "Arial", sans-serif;
  940. }
  941. .file-node-content:hover .file-node-icon,
  942. .file-node-content:hover .file-node-open-state {
  943. visibility: visible;
  944. }
  945. .mac-seamless-mode #typora-sidebar {
  946. background-color: #fafafa;
  947. background-color: var(--side-bar-bg-color);
  948. }
  949. .md-lang {
  950. color: #b4654d;
  951. }
  952. .html-for-mac .context-menu {
  953. --item-hover-bg-color: #E6F0FE;
  954. }
  955. #md-notification .btn {
  956. border: 0;
  957. }
  958. .dropdown-menu .divider {
  959. border-color: #e5e5e5;
  960. }
  961. .ty-preferences .window-content {
  962. background-color: #fafafa;
  963. }
  964. .ty-preferences .nav-group-item.active {
  965. color: white;
  966. background: #999;
  967. }
  968. .typora-export li, .typora-export p, .typora-export, .footnote-line {
  969. white-space: normal;
  970. }
  971. </style>
  972. </head>
  973. <body class='typora-export os-windows'>
  974. <div id='write' class='is-node'>
  975. '''
  976. post_content='''
  977. </div>
  978. </body>
  979. </html>
  980. '''
  981. def main(argv):
  982. in_file = argv[0]
  983. out_file = argv[1]
  984. input_file = codecs.open(in_file, mode="r", encoding="utf-8")
  985. text = input_file.read()
  986. html = markdown.markdown(text)
  987. output_file = codecs.open(out_file, "w",encoding="utf-8",errors="xmlcharrefreplace")
  988. output_file.write(pre_content+html+post_content)
  989. if __name__ == "__main__":
  990. main(sys.argv[1:])