X-Git-Url: https://git.ralfj.de/rust-101.git/blobdiff_plain/706bf6cb37885ca97a49f772de00b535cf3dbf9f..a610bd0f496392b0a49640ea931302110570ed6d:/pycco-rs diff --git a/pycco-rs b/pycco-rs index b1d7f43..d250b20 100755 --- a/pycco-rs +++ b/pycco-rs @@ -2,7 +2,13 @@ # A little wrapper around pycco, to add Rust support. import pycco, pycco_resources from pygments import lexers, formatters -import re +import sys, re + +# helper functions +def patch_html(source, marker, new_text): + '''Find the [marker] in [source], and insert [new_text] after it.''' + assert source.count(marker) == 1 + return source.replace(marker, marker + new_text, 1) # now, monkey-patch pycco for Rust support pycco.main.languages[".rs"] = { "name": "rust", "symbol": "//"} @@ -17,19 +23,27 @@ for ext, l in pycco.main.languages.items(): l["divider_html"] = re.compile(r'\n*' + l["symbol"] + 'DIVIDER\n*') # Get the Pygments Lexer for this language. l["lexer"] = lexers.get_lexer_by_name(l["name"]) -# and monkey-patch for a custom CSS file -html_src = pycco_resources.html - -css_marker = '' -custom_css = '' -assert html_src.count(css_marker) == 1 -html_src = html_src.replace(css_marker, css_marker+custom_css, 1) - -title_marker = '
()?