-
-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ways to disable or customize ##
comments?
#268
Comments
Michael Bayer (@zzzeek) wrote: the preprocessor is there for this use case. What's inefficient about it? |
Michael Bayer (@zzzeek) wrote: well your preprocessor looks a little complicated...usually the |
Adam Twardoch (@twardoch) wrote: The thing is that I’d effectively have to wrap 99.5% of my content in <%text>, which sort of defeats the purpose. My Markdown documents are regular Markdown documents, mostly. I don’t want to mark them up specially just in case I process it with Mako (i.e. they serve as a Mako template). I have a team of editors who are working on the documents. Only occasionally I want to use Mako constructs (usually module-level Python blocks, normal Python blocks, then sometimes Mako expressions and other constructs like for loops or ifs). Mako serves my purposes perfectly, except for one thing — the inline Mako comments. Because of them, I have to do awkward things to my code that runs Mako. My Python Markdown extension slows the process down because of the extra regex substitution done twice — I have to replace So I wonder what the method would be to "disable" the Mako inline comments in some other way. |
Adam Twardoch (@twardoch) wrote: Ps. So are you saying I should regex-replace |
Michael Bayer (@zzzeek) wrote: pretty much, either |
The checklist template is processed by Mako, which uses `##` as template comment. Use syntax which avoids stripping the headings out. (The Mako comment behavior cannot really be configured; we could write a pre-processor which does the escaping, but since we're only having a single template here and many invocations of Mako in different scripts, doing that seems fragile. See also sqlalchemy/mako#268.) Signed-off-by: Philipp Wagner <[email protected]>
The checklist template is processed by Mako, which uses `##` as template comment. Use syntax which avoids stripping the headings out. (The Mako comment behavior cannot really be configured; we could write a pre-processor which does the escaping, but since we're only having a single template here and many invocations of Mako in different scripts, doing that seems fragile. See also sqlalchemy/mako#268.) Signed-off-by: Philipp Wagner <[email protected]>
Migrated issue, originally created by Adam Twardoch (@twardoch)
I'm using Mako to process not HTML but other types of human-readable documents, specifically:
By "process" I mean that I have files written in such a dialect with Mako inserts (so they're templates) and I use the Mako code to fill in some data and generate a final document in the same dialect.
I highly value the fact that Mako allows direct and simple embedding of Python blocks into the templates and does not insist on putting logic into some complicated external modules (like for instance Jinja2 does). This aspect of Mako is really great. I'm not concerned with super-high performance because my Mako templates are deployed in a very controlled scenarios.
One common thing to all those dialects is that they use single-line comments prefixed by
#
or sometimes##
. In case of Markdown, these are not comments of course but##
actually stands for H2 headings.But Mako interprets
##
as its own comments, which interfers with those dialects.For my
md_mako
extension for Python Markdown, which preprocesses Markdown with embedded Mako portions and returns regularized Markdown:I used a stupid trick (replacing
##
with a stub string before calling Mako, and then reversing the change afterwards). But this is very inefficient.So: how can I prevent those from processing those single-line Mako comments that are prefixed with
##
? I could settle for specifying another more elaborate prefix instead or not having such comments at all.In other words: I want Mako to treat lines that start with
##
like any other text lines.How do I do that?
The text was updated successfully, but these errors were encountered: