Markdown css - a command tool to convert css style into markdown inline style

  • By null
  • Last update: Dec 30, 2022
  • Comments: 5

makrdown-css

pypi

Markdown css is a command tool to convert css style into markdown inline style.

中文文档 演示

Theme Demo

apollo.css

ocean.css

simple.css

style.css

typing.css

xiaolai.css

Install

maxOS

xcode-select --install
pip install markdown-css

linux

apt-get install libxml2-dev libxslt1-dev python-dev
apt-get install python-lxml
pip install markdown-css

Getting started

pip install markdown-css
mkdir public
touch style.css
markdown -h
markdown-css markdown.html --style=style.css --out=public

Themes

https://github.com/wecatch/markdown-css/tree/master/themes

Demo

git clone https://github.com/wecatch/markdown-css.git
cd themes
markdown-css markdown.html --style=simple.css --out=public

Selector

markdown-css support css selector like these:

element selector

p {
    margin: 10px 0;
}

multi element selector

h1,p,h2,pre {
    color: #333;
}

all element

* {
    font-size: 14px
}

pseudo-selector

h1:before {
    content: '#'
}

child element seletor

blockquote p {
    color:#888;
}

Pseudo-selector can't be used in inline-style, these selectos are write into

Github

https://github.com/wecatch/markdown-css

Comments(5)

  • 1

    Pseudo Class can't copy to WeChat Edit

    I use markdown-css, and I found the html is appear well, but when I copy the html into Wechat Edit, all the Pseudo Class is disappear. Is there any solution?

  • 2

    lxml.etree.XMLSyntaxError: None

    markdown-css test.html --style=style.css --out=public Traceback (most recent call last): File "/usr/local/bin/markdown-css", line 72, in main(input_file, out, style, name) File "/usr/local/bin/markdown-css", line 30, in main html = PyQuery(content) File "/usr/local/lib/python2.7/dist-packages/pyquery/pyquery.py", line 226, in init elements = fromstring(context, self.parser) File "/usr/local/lib/python2.7/dist-packages/pyquery/pyquery.py", line 70, in fromstring result = getattr(lxml.html, meth)(context) File "/usr/lib/python2.7/dist-packages/lxml/html/init.py", line 704, in fromstring doc = document_fromstring(html, parser=parser, base_url=base_url, **kw) File "/usr/lib/python2.7/dist-packages/lxml/html/init.py", line 600, in document_fromstring value = etree.fromstring(html, parser, **kw) File "lxml.etree.pyx", line 3032, in lxml.etree.fromstring (src/lxml/lxml.etree.c:68106) File "parser.pxi", line 1785, in lxml.etree._parseMemoryDocument (src/lxml/lxml.etree.c:102455) File "parser.pxi", line 1666, in lxml.etree._parseDoc (src/lxml/lxml.etree.c:101214) File "parser.pxi", line 1035, in lxml.etree._BaseParser._parseUnicodeDoc (src/lxml/lxml.etree.c:96124 ) File "parser.pxi", line 582, in lxml.etree._ParserContext._handleParseResultDoc (src/lxml/lxml.etree. c:91275) File "parser.pxi", line 683, in lxml.etree._handleParseResult (src/lxml/lxml.etree.c:92461) File "parser.pxi", line 633, in lxml.etree._raiseParseError (src/lxml/lxml.etree.c:91924) lxml.etree.XMLSyntaxError: None

  • 3

    docopt get default value is None

     File "/Users/zhyq0826/workspace/python_dev/lib/python2.7/genericpath.py", line 49, in isdir
        st = os.stat(s)
    TypeError: coercing to Unicode: need string or buffer, NoneType found
    
  • 4

    Bump pygments from 2.4.0 to 2.7.4

    Bumps pygments from 2.4.0 to 2.7.4.

    Release notes

    Sourced from pygments's releases.

    2.7.4

    • Updated lexers:

      • Apache configurations: Improve handling of malformed tags (#1656)

      • CSS: Add support for variables (#1633, #1666)

      • Crystal (#1650, #1670)

      • Coq (#1648)

      • Fortran: Add missing keywords (#1635, #1665)

      • Ini (#1624)

      • JavaScript and variants (#1647 -- missing regex flags, #1651)

      • Markdown (#1623, #1617)

      • Shell

        • Lex trailing whitespace as part of the prompt (#1645)
        • Add missing in keyword (#1652)
      • SQL - Fix keywords (#1668)

      • Typescript: Fix incorrect punctuation handling (#1510, #1511)

    • Fix infinite loop in SML lexer (#1625)

    • Fix backtracking string regexes in JavaScript/TypeScript, Modula2 and many other lexers (#1637)

    • Limit recursion with nesting Ruby heredocs (#1638)

    • Fix a few inefficient regexes for guessing lexers

    • Fix the raw token lexer handling of Unicode (#1616)

    • Revert a private API change in the HTML formatter (#1655) -- please note that private APIs remain subject to change!

    • Fix several exponential/cubic-complexity regexes found by Ben Caller/Doyensec (#1675)

    • Fix incorrect MATLAB example (#1582)

    Thanks to Google's OSS-Fuzz project for finding many of these bugs.

    2.7.3

    ... (truncated)

    Changelog

    Sourced from pygments's changelog.

    Version 2.7.4

    (released January 12, 2021)

    • Updated lexers:

      • Apache configurations: Improve handling of malformed tags (#1656)

      • CSS: Add support for variables (#1633, #1666)

      • Crystal (#1650, #1670)

      • Coq (#1648)

      • Fortran: Add missing keywords (#1635, #1665)

      • Ini (#1624)

      • JavaScript and variants (#1647 -- missing regex flags, #1651)

      • Markdown (#1623, #1617)

      • Shell

        • Lex trailing whitespace as part of the prompt (#1645)
        • Add missing in keyword (#1652)
      • SQL - Fix keywords (#1668)

      • Typescript: Fix incorrect punctuation handling (#1510, #1511)

    • Fix infinite loop in SML lexer (#1625)

    • Fix backtracking string regexes in JavaScript/TypeScript, Modula2 and many other lexers (#1637)

    • Limit recursion with nesting Ruby heredocs (#1638)

    • Fix a few inefficient regexes for guessing lexers

    • Fix the raw token lexer handling of Unicode (#1616)

    • Revert a private API change in the HTML formatter (#1655) -- please note that private APIs remain subject to change!

    • Fix several exponential/cubic-complexity regexes found by Ben Caller/Doyensec (#1675)

    • Fix incorrect MATLAB example (#1582)

    Thanks to Google's OSS-Fuzz project for finding many of these bugs.

    Version 2.7.3

    (released December 6, 2020)

    ... (truncated)

    Commits
    • 4d555d0 Bump version to 2.7.4.
    • fc3b05d Update CHANGES.
    • ad21935 Revert "Added dracula theme style (#1636)"
    • e411506 Prepare for 2.7.4 release.
    • 275e34d doc: remove Perl 6 ref
    • 2e7e8c4 Fix several exponential/cubic complexity regexes found by Ben Caller/Doyensec
    • eb39c43 xquery: fix pop from empty stack
    • 2738778 fix coding style in test_analyzer_lexer
    • 02e0f09 Added 'ERROR STOP' to fortran.py keywords. (#1665)
    • c83fe48 support added for css variables (#1633)
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

  • 5

    Chrome 浏览器复制文章内容到微信公众号编辑器带上了字体

    用 Chrome 最新的浏览器打开 markdown-css 生成的 html ,如果 css 不指定任何字体,也就是没有 font-family,复制到微信编辑器之后会内联 css 会带上 font-family: "PingFang SC" ,由于微信公众号没有这个字体,微信会把 css 样式去掉,格式会乱,解决方法是

    1. 换用其他浏览器,mac 上 Safari 可以
    2. css 中指定 font-family,但字体一定要在微信自带的浏览器中存在