Skip to content
Discussion options

You must be logged in to vote

alright, I have fixed this via the following method:

So my workflow is, I have a "raw posts" directory where I write normal markdown, then I run a script which embeds all latex into {::nomarkdown} and saves to "_posts" directory. Here is the embedding part:

def wrap_math(content: str):
    """
    Wraps $...$ and $$...$$ into {::nomarkdown}
    """
    # for $..$
    p1 = r'\$[^\n\$]+\$'

    # for $$..$$
    p2 = r'\$\$[\s\S]*?\$\$'

    pattern = re.compile(f'({p2})|({p1})')

    def replacer(match):
        return f"{{::nomarkdown}}{match.group(0)}{{:/nomarkdown}}"

    return pattern.sub(replacer, content)

so for example I do this

with open(Path("raw_posts") / name, "r", encoding='utf8'

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by inikishev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant