Skip to content
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

can't use curly braces in my doc #17

Open
makayabou opened this issue Jan 1, 2021 · 1 comment
Open

can't use curly braces in my doc #17

makayabou opened this issue Jan 1, 2021 · 1 comment

Comments

@makayabou
Copy link

Hi,
I'm having an issue trying to render curly braces in documentation (doc for jinja2 templates)

I'm looking to render something simple like:

{{ define "main" }}

I found 4 ways for that:

1. {% raw %} {{ define "main" }} {% endraw %} 
2. <!-- {% raw %} --> {{ define "main" }}   <!-- {% endraw %} --> 
3. {\{ define "main" }}
4. {{ define "main" }}   

Problem is:

Online

on gitlab pages :

  • method 1 renders {% raw%} {{ define "main" }} (hiding {% endraw %})
  • method 2 & 3 & 4 work

on my computer (Debian 10)

(with mkdocs installed via pip3 and requirements via requirements.txt):

  • method 1, 2 and 3 work ,
  • method 4 breaks build:
ERROR   -  Error reading page 'raw_test.md': expected token 'end of print statement', got 'string' 
  Traceback (most recent call last):
    File "/home/makayabou/.local/bin/mkdocs", line 10, in <module>
      sys.exit(cli())
    File "/home/makayabou/.local/lib/python3.7/site-packages/click/core.py", line 829, in __call__
      return self.main(*args, **kwargs)
    File "/home/makayabou/.local/lib/python3.7/site-packages/click/core.py", line 782, in main
      rv = self.invoke(ctx)
    File "/home/makayabou/.local/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
      return _process_result(sub_ctx.command.invoke(sub_ctx))
    File "/home/makayabou/.local/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
      return ctx.invoke(self.callback, **ctx.params)
    File "/home/makayabou/.local/lib/python3.7/site-packages/click/core.py", line 610, in invoke
      return callback(*args, **kwargs)
    File "/home/makayabou/.local/lib/python3.7/site-packages/mkdocs/__main__.py", line 136, in serve_command
      **kwargs
    File "/home/makayabou/.local/lib/python3.7/site-packages/mkdocs/commands/serve.py", line 141, in serve
      config = builder()
    File "/home/makayabou/.local/lib/python3.7/site-packages/mkdocs/commands/serve.py", line 136, in builder
      build(config, live_server=live_server, dirty=dirty)
    File "/home/makayabou/.local/lib/python3.7/site-packages/mkdocs/commands/build.py", line 271, in build
      _populate_page(file.page, config, files, dirty)
    File "/home/makayabou/.local/lib/python3.7/site-packages/mkdocs/commands/build.py", line 168, in _populate_page
      'page_markdown', page.markdown, page=page, config=config, files=files
    File "/home/makayabou/.local/lib/python3.7/site-packages/mkdocs/plugins.py", line 94, in run_event
      result = method(item, **kwargs)
    File "/home/makayabou/.local/lib/python3.7/site-packages/mkdocs_git_revision_date_plugin/plugin.py", line 57, in on_page_markdown
      md_template = Template(markdown)
    File "/home/makayabou/.local/lib/python3.7/site-packages/jinja2/environment.py", line 1031, in __new__
      return env.from_string(source, template_class=cls)
    File "/home/makayabou/.local/lib/python3.7/site-packages/jinja2/environment.py", line 941, in from_string
      return cls.from_code(self, self.compile(source), globals, None)
    File "/home/makayabou/.local/lib/python3.7/site-packages/jinja2/environment.py", line 638, in compile
      self.handle_exception(source=source_hint)
    File "/home/makayabou/.local/lib/python3.7/site-packages/jinja2/environment.py", line 832, in handle_exception
      reraise(*rewrite_traceback_stack(source=source))
    File "/home/makayabou/.local/lib/python3.7/site-packages/jinja2/_compat.py", line 28, in reraise
      raise value.with_traceback(tb)
    File "<unknown>", line 16, in template
  jinja2.exceptions.TemplateSyntaxError: expected token 'end of print statement', got 'string'

Files

Here is my mkdocs.yml :

site_name: Garage Num Doc
site_url: https://garagenum.gitlab.io/doc
site_dir: public
theme: 
    name: material
    custom_dir: overrides
    features:
        - navigation.instant
        - navigation.expand
        - navigation.tabs
plugins:
    - search:
        min_search_length: 2
    - add-number:
        order: 2
        excludes:
            - divers/cmd/
        includes:
            - divers/cmd/screen
    - git-authors  
    - git-revision-date
markdown_extensions:
    - admonition
    - pymdownx.tabbed
    - pymdownx.details
    - pymdownx.superfences:
        custom_fences:
          - name: mermaid
            class: mermaid
            format: !!python/name:pymdownx.superfences.fence_div_format
    - pymdownx.highlight:
        use_pygments: false
        linenums_style: pymdownx.inline
    - pymdownx.inlinehilite
    - pymdownx.keys
    - footnotes
    - toc:
        permalink: true
    - attr_list

and here is my requirements.txt

mkdocs>=1.1.2
mkdocs-material>=5.4.0
Pygments
git+https://github.com/pugong/mkdocs-mermaid-plugin
mkdocs-git-authors-plugin
mkdocs-git-revision-date-plugin
mkdocs-add-number-plugin

Maybe you will also need my .gitlab-ci.yml:

image: python:3.8-buster

before_script:
  - pip install -r requirements.txt

pages:
  stage: deploy
  script:
  - mkdocs build --strict --verbose
  only:
  - master

I had reported that to mkdocs but they pointed me to you as says traceback . mkdocs/mkdocs#2275

thanks

@jheck88
Copy link

jheck88 commented Oct 19, 2022

Bump, seeing the exact same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants