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

Header anchor missing end of comment tag processing content produced with attribute lists #208

Closed
jodygarnett opened this issue Feb 13, 2024 · 8 comments
Assignees
Labels
enhancement New feature or request fixed A fix has been submitted

Comments

@jodygarnett
Copy link

I have gotten stuck on an interesting challenge, I am cleaning up some docs converted with pandoc resulting in headers with attribute_list snippets information.

## Installing the Db2 extension {#Db2_install}

This falls squarely into the User Manual "Elsewhere" Solution 5

plugins:
  - macros:
      render_by_default: false
      on_error_fail: true
      on_undefined: keep
      j2_block_start_string: '[[%'
      j2_block_end_string: '%]]'
      j2_variable_start_string: '[['
      j2_variable_end_string: ']]'

These settings are picked up:

INFO    -  Building documentation...
INFO    -  [macros] - Macros arguments: {'module_name': 'main', 'modules': [], 'render_by_default': False, 'include_dir': '', 'include_yaml': [], 'j2_block_start_string': '[[%', 'j2_block_end_string': '%]]', 'j2_variable_start_string': '[[', 'j2_variable_end_string': ']]', 'on_undefined':
           'keep', 'on_error_fail': True, 'verbose': False}
INFO    -  [macros] - Extra variables (config file): ['homepage', 'social', 'version', 'release']
INFO    -  [macros] - Extra filters (module): ['pretty']
INFO    -  [macros] - Found j2 variable 'block_start_string': '[[%'
INFO    -  [macros] - Found j2 variable 'block_end_string': '%]]'
INFO    -  [macros] - Found j2 variable 'variable_start_string': '[['
INFO    -  [macros] - Found j2 variable 'variable_end_string': ']]'

But stumble on {#identifier}:

INFO    -  [macros] - ERROR # _Macro Syntax Error_

           _File_: `data/database/h2.md`

           _Line 7 in Markdown file:_ **Missing end of comment tag**
           ```markdown
           ## Installing the H2 extension {#h2_install}
           ```

Is there a need for a j2_comment_start_string and j2_comment_end_string ?

Copy link

Welcome to this project and thank you!' first issue

@jodygarnett
Copy link
Author

As a workaround I am going to try and post process the content to:

## Installing the Db2 extension {: #Db2_install }

@fralau
Copy link
Owner

fralau commented Feb 13, 2024

Could be 🤔

For reference,

Are you willing to propose a PR and test whether it solves the problem for you?

@fralau fralau added planned This is planned for correction enhancement New feature or request and removed planned This is planned for correction labels Feb 13, 2024
@jodygarnett
Copy link
Author

My workaround (post processing) was successful ; but I know how frustrating it is if people do not report issues.


I am nominally a java developer so I am afraid I am embarrassed to try hacking at Python code.

  1. Let me check if Jina2 supports customization of comment start / end string...
  2. Checking for code you are following naming convention and adding to "Environment"
  3. Looking at Jinja documentation comment_start_string and comment_end_string are documented as parameters
  4. I am not sure how Environment is handed over to Jinja as paramaters but it is worth a test

@fralau
Copy link
Owner

fralau commented Feb 14, 2024

@jodygarnett No problem. If you prefer, I can do the change and it might still be fun for you to have a look at the diff?

When I didn't know anything at all of Python, I chose a super simple and short manual called Python Phrasebook; it was easy reading, and I completed it in a couple of evenings. It gave the few central ideas on which I could build all the rest. You might need a more recent book, because it covers Python 2 (instead of Python 3), but it's the approach that worked for me.

@fralau fralau added the planned This is planned for correction label Feb 14, 2024
fralau pushed a commit that referenced this issue Feb 17, 2024
  - Now it is possible to specify to additional standard jinja2
    parameters, e.g.
    j2_comment_start_string: '[#'
    j2_comment_end_string: '#]'
  - Updated documentation
  - Updated `new_syntax` use case
@fralau
Copy link
Owner

fralau commented Feb 17, 2024

I pushed an update on github with e.g.:

plugins:
  - search
  - macros:
      j2_block_start_string: '[[%'
      j2_block_end_string: '%]]'
      j2_variable_start_string: '[['
      j2_variable_end_string: ']]'
      j2_comment_start_string: '[#'
      j2_comment_end_string: '#]'

I also updated the new_syntax website (in the test directory) and checked that it works.

Could you try it for your use case and let me know if it works?

@fralau fralau added fixed A fix has been submitted info required Further information is requested please test An updated was pushed. This needs to be tested and removed planned This is planned for correction info required Further information is requested labels Feb 17, 2024
@jodygarnett
Copy link
Author

Yes happy to try, just need to figure out how to test from GitHub.

@fralau
Copy link
Owner

fralau commented Feb 23, 2024

Thanks! The best thing is to git clone (or download zip) and install from there.

Capture d’écran 2024-02-23 à 11 31 47

@fralau fralau added the stale No news, closing label Mar 9, 2024
@fralau fralau removed stale No news, closing please test An updated was pushed. This needs to be tested labels Apr 9, 2024
@fralau fralau closed this as completed Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fixed A fix has been submitted
Projects
None yet
Development

No branches or pull requests

2 participants