日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python之markdown转html

發布時間:2025/6/17 python 49 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python之markdown转html 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

python之markdown轉html

  • 為了方便,定義一個markdown轉html的函數,直接調用即可
import markdowndef md2html(mdstr):exts = ['markdown.extensions.extra', 'markdown.extensions.codehilite','markdown.extensions.tables','markdown.extensions.toc']html = '''<html lang="zh-cn"><head><meta content="text/html; charset=utf-8" http-equiv="content-type" /><link href="/static/default.css" rel="stylesheet"><link href="/static/github.css" rel="stylesheet"></head><body>%s</body></html>'''ret = markdown(mdstr,extensions=exts)return html % ret
  • 注意:
  • pip install markdown
  • 創建default.css和github.css

  • default.css

    .hll { background-color: #ffffcc } .c { color: #408080; font-style: italic } /* Comment */ .err { border: 1px solid #FF0000 } /* Error */ .k { color: #008000; font-weight: bold } /* Keyword */ .o { color: #666666 } /* Operator */ .ch { color: #408080; font-style: italic } /* Comment.Hashbang */ .cm { color: #408080; font-style: italic } /* Comment.Multiline */ .cp { color: #BC7A00 } /* Comment.Preproc */ .cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */ .c1 { color: #408080; font-style: italic } /* Comment.Single */ .cs { color: #408080; font-style: italic } /* Comment.Special */ .gd { color: #A00000 } /* Generic.Deleted */ .ge { font-style: italic } /* Generic.Emph */ .gr { color: #FF0000 } /* Generic.Error */ .gh { color: #000080; font-weight: bold } /* Generic.Heading */ .gi { color: #00A000 } /* Generic.Inserted */ .go { color: #888888 } /* Generic.Output */ .gp { color: #000080; font-weight: bold } /* Generic.Prompt */ .gs { font-weight: bold } /* Generic.Strong */ .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ .gt { color: #0044DD } /* Generic.Traceback */ .kc { color: #008000; font-weight: bold } /* Keyword.Constant */ .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */ .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */ .kp { color: #008000 } /* Keyword.Pseudo */ .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */ .kt { color: #B00040 } /* Keyword.Type */ .m { color: #666666 } /* Literal.Number */ .s { color: #BA2121 } /* Literal.String */ .na { color: #7D9029 } /* Name.Attribute */ .nb { color: #008000 } /* Name.Builtin */ .nc { color: #0000FF; font-weight: bold } /* Name.Class */ .no { color: #880000 } /* Name.Constant */ .nd { color: #AA22FF } /* Name.Decorator */ .ni { color: #999999; font-weight: bold } /* Name.Entity */ .ne { color: #D2413A; font-weight: bold } /* Name.Exception */ .nf { color: #0000FF } /* Name.Function */ .nl { color: #A0A000 } /* Name.Label */ .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */ .nt { color: #008000; font-weight: bold } /* Name.Tag */ .nv { color: #19177C } /* Name.Variable */ .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */ .w { color: #bbbbbb } /* Text.Whitespace */ .mb { color: #666666 } /* Literal.Number.Bin */ .mf { color: #666666 } /* Literal.Number.Float */ .mh { color: #666666 } /* Literal.Number.Hex */ .mi { color: #666666 } /* Literal.Number.Integer */ .mo { color: #666666 } /* Literal.Number.Oct */ .sa { color: #BA2121 } /* Literal.String.Affix */ .sb { color: #BA2121 } /* Literal.String.Backtick */ .sc { color: #BA2121 } /* Literal.String.Char */ .dl { color: #BA2121 } /* Literal.String.Delimiter */ .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */ .s2 { color: #BA2121 } /* Literal.String.Double */ .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */ .sh { color: #BA2121 } /* Literal.String.Heredoc */ .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */ .sx { color: #008000 } /* Literal.String.Other */ .sr { color: #BB6688 } /* Literal.String.Regex */ .s1 { color: #BA2121 } /* Literal.String.Single */ .ss { color: #19177C } /* Literal.String.Symbol */ .bp { color: #008000 } /* Name.Builtin.Pseudo */ .fm { color: #0000FF } /* Name.Function.Magic */ .vc { color: #19177C } /* Name.Variable.Class */ .vg { color: #19177C } /* Name.Variable.Global */ .vi { color: #19177C } /* Name.Variable.Instance */ .vm { color: #19177C } /* Name.Variable.Magic */ .il { color: #666666 } /* Literal.Number.Integer.Long */

    github.css

    body {font-family: Helvetica, arial, sans-serif;font-size: 14px;line-height: 1.6;padding-top: 10px;padding-bottom: 10px;background-color: white;padding: 30px; }body > *:first-child {margin-top: 0 !important; } body > *:last-child {margin-bottom: 0 !important; }a {color: #4183C4; } a.absent {color: #cc0000; } a.anchor {display: block;padding-left: 30px;margin-left: -30px;cursor: pointer;position: absolute;top: 0;left: 0;bottom: 0; }h1, h2, h3, h4, h5, h6 {margin: 20px 0 10px;padding: 0;font-weight: bold;-webkit-font-smoothing: antialiased;cursor: text;position: relative; }h1:hover a.anchor, h2:hover a.anchor, h3:hover a.anchor, h4:hover a.anchor, h5:hover a.anchor, h6:hover a.anchor {background: url("../../images/modules/styleguide/para.png") no-repeat 10px center;text-decoration: none; }h1 tt, h1 code {font-size: inherit; }h2 tt, h2 code {font-size: inherit; }h3 tt, h3 code {font-size: inherit; }h4 tt, h4 code {font-size: inherit; }h5 tt, h5 code {font-size: inherit; }h6 tt, h6 code {font-size: inherit; }h1 {font-size: 28px;color: black; }h2 {font-size: 24px;border-bottom: 1px solid #cccccc;color: black; }h3 {font-size: 18px; }h4 {font-size: 16px; }h5 {font-size: 14px; }h6 {color: #777777;font-size: 14px; }p, blockquote, ul, ol, dl, li, table, pre {margin: 15px 0; }hr {background: transparent url("../../images/modules/pulls/dirty-shade.png") repeat-x 0 0;border: 0 none;color: #cccccc;height: 4px;padding: 0; }body > h2:first-child {margin-top: 0;padding-top: 0; } body > h1:first-child {margin-top: 0;padding-top: 0; }body > h1:first-child + h2 {margin-top: 0;padding-top: 0; } body > h3:first-child, body > h4:first-child, body > h5:first-child, body > h6:first-child {margin-top: 0;padding-top: 0; }a:first-child h1, a:first-child h2, a:first-child h3, a:first-child h4, a:first-child h5, a:first-child h6 {margin-top: 0;padding-top: 0; }h1 p, h2 p, h3 p, h4 p, h5 p, h6 p {margin-top: 0; }li p.first {display: inline-block; }ul, ol {padding-left: 30px; }ul :first-child, ol :first-child {margin-top: 0; }ul :last-child, ol :last-child {margin-bottom: 0; }dl {padding: 0; }dl dt {font-size: 14px;font-weight: bold;font-style: italic;padding: 0;margin: 15px 0 5px; }dl dt:first-child {padding: 0; }dl dt > :first-child {margin-top: 0; }dl dt > :last-child {margin-bottom: 0; }dl dd {margin: 0 0 15px;padding: 0 15px; }dl dd > :first-child {margin-top: 0; }dl dd > :last-child {margin-bottom: 0; }blockquote {border-left: 4px solid #dddddd;padding: 0 15px;color: #777777; }blockquote > :first-child {margin-top: 0; }blockquote > :last-child {margin-bottom: 0; }table {padding: 0; }table tr {border-top: 1px solid #cccccc;background-color: white;margin: 0;padding: 0; }table tr:nth-child(2n) {background-color: #f8f8f8; }table tr th {font-weight: bold;border: 1px solid #cccccc;text-align: left;margin: 0;padding: 6px 13px; }table tr td {border: 1px solid #cccccc;text-align: left;margin: 0;padding: 6px 13px; }table tr th :first-child, table tr td :first-child {margin-top: 0; }table tr th :last-child, table tr td :last-child {margin-bottom: 0; }img {max-width: 100%; }span.frame {display: block;overflow: hidden; }span.frame > span {border: 1px solid #dddddd;display: block;float: left;overflow: hidden;margin: 13px 0 0;padding: 7px;width: auto; }span.frame span img {display: block;float: left; }span.frame span span {clear: both;color: #333333;display: block;padding: 5px 0 0; } span.align-center {display: block;overflow: hidden;clear: both; }span.align-center > span {display: block;overflow: hidden;margin: 13px auto 0;text-align: center; }span.align-center span img {margin: 0 auto;text-align: center; } span.align-right {display: block;overflow: hidden;clear: both; }span.align-right > span {display: block;overflow: hidden;margin: 13px 0 0;text-align: right; }span.align-right span img {margin: 0;text-align: right; } span.float-left {display: block;margin-right: 13px;overflow: hidden;float: left; }span.float-left span {margin: 13px 0 0; } span.float-right {display: block;margin-left: 13px;overflow: hidden;float: right; }span.float-right > span {display: block;overflow: hidden;margin: 13px auto 0;text-align: right; }code, tt {margin: 0 2px;padding: 0 5px;white-space: nowrap;border: 1px solid #eaeaea;background-color: #f8f8f8;border-radius: 3px; }pre code {margin: 0;padding: 0;white-space: pre;border: none;background: transparent; }.highlight pre {background-color: #f8f8f8;border: 1px solid #cccccc;font-size: 13px;line-height: 19px;overflow: auto;padding: 6px 10px;border-radius: 3px; }pre {background-color: #f8f8f8;border: 1px solid #cccccc;font-size: 13px;line-height: 19px;overflow: auto;padding: 6px 10px;border-radius: 3px; }pre code, pre tt {background-color: transparent;border: none; }

    轉載于:https://www.cnblogs.com/PrettyTom/p/6986904.html

    總結

    以上是生活随笔為你收集整理的python之markdown转html的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

    主站蜘蛛池模板: 蜜桃网站| 日韩电影二区 | 国模私拍在线观看 | 国产精欧美一区二区三区蓝颜男同 | 在线a网站 | 国产精品视频h | 91挑色| 三级黄色免费 | 欧美黑人精品一区二区不卡 | 第四色激情 | 欧美亚洲一区二区在线观看 | 91xxx在线观看 | 亚洲永久在线观看 | 在线日本视频 | 波多野在线播放 | 日韩大片在线 | 丝袜诱惑一区二区 | 久久亚洲av午夜福利精品一区 | 亚洲做受高潮无遮挡 | 亚洲第一天堂久久 | 少妇高潮一区二区三区99小说 | 欧洲丰满少妇做爰 | 91色网站 | 国产精品性| 一本色道久久综合狠狠躁 | 土耳其xxxx性hd极品 | www.偷拍.com | 天天综合网天天综合色 | 91色| 亚洲精品推荐 | 五月婷婷丁香在线 | 女女同性女同一区二区三区按摩 | 各种含道具高h调教1v1男男 | 亚洲av无码一区二区三区四区 | 欧美最猛黑人xxxx黑人猛交 | 国产免费网| 国产精品久久国产精品 | 国产一级α片 | 欧美综合另类 | 国产精品国产精品国产 | 美女视频黄a视频全免费观看 | 91av国产精品 | 国产精品区二区三区日本 | 精品91久久久久久 | 青春草在线视频观看 | 免费一级片网址 | 午夜成人亚洲理伦片在线观看 | 看毛片网| 亚洲宅男天堂 | 天天射视频 | www.黄色网址.com | 成人3d动漫一区二区三区91 | 丁香亚洲 | 亚欧成人在线 | 性色av一区二区三区免费 | 玉女心经在线看 | 3d动漫精品啪啪一区二区竹菊 | 好吊妞这里只有精品 | 亚洲激情 | 亚洲AV无码AV吞精久久中文版 | 免费日批网站 | 午夜天堂影院 | 奇米中文字幕 | 亚洲风情亚aⅴ在线发布 | 精品久久久久久无码人妻 | 亚洲国产精品久久久久久久 | av毛片网 | 中文字幕在线视频日韩 | 亚洲视频精品在线观看 | 中文字幕激情 | 老司机在线免费视频 | 欧美高清视频一区 | 97免费看 | 精品久久久久久无码中文野结衣 | 国产中文字幕乱人伦在线观看 | 校园激情av | 高跟鞋丝袜猛烈xxxx | 国产精品一级二级 | 亚洲成人av综合 | 一级黄色片视频 | 高h文在线| 美女毛片在线观看 | 激情视频久久 | 欧美理论片在线观看 | 性人久久久久 | 在线观看视频你懂得 | 黄色一级大片 | 久久99精品久久久 | 日韩精品xxx | 天天干天天草天天射 | 欧美在线观看一区二区 | 午夜久久影院 | 日韩www视频 | 中文字幕乱码人妻一区二区三区 | 99热在 | 少妇av一区二区三区 | 正在播放亚洲 | 九月婷婷 | 精品一区二区人妻 |