mfarragher / obsidiantools

Obsidian tools - a Python package for analysing an Obsidian.md vault
Other
402 stars 28 forks source link

Tags in code blocks are taken #24

Closed louis030195 closed 1 year ago

louis030195 commented 1 year ago

As a placeholder. I think code blocks should be ignored for tags? What do you think?

image
 "file_tags": [
        "meta",
        "idea",
        "shower-thought",
        "to-digest",
        "shower-thought",
        "introduction",
        "shower-thought\"",
        "guru\"",
        "shroedinger-uncertain\"",
        "floating-point-error\"",
        "socratic\""
      ]
mfarragher commented 1 year ago

When I add this to Sussudio.md:

#code_comment_not_tag
#code-comment-not-tag

The current test test_tags_index still passes, as desired.

But when I add this:

# #code_comment_not_tag
# #code-comment-not-tag

The code processes those Python comments as two tags.

mfarragher commented 1 year ago

Via _get_html_from_md_file function, the HTML was getting recognised as:

<p>```python</p>
<h1>#code_comment_not_tag</h1>
<h1>#code-comment-not-tag</h1>
<p>```</p>

Adding superfences extension (https://github.com/mfarragher/obsidiantools/commit/228ec4bfa6637551ea7fa4e28ff1fb82c53f740e), this is better, as everything in the code tag gets wiped out as expected:

<div class="highlight"><pre><span></span><code><span class="c1"># #code_comment_not_tag</span>
<span class="c1"># #code-comment-not-tag</span>
</code></pre></div>
mfarragher commented 1 year ago

Tests pass for this now: https://github.com/mfarragher/obsidiantools/commit/073881b94da5c7d429b9e5f926027088833d33c6

I added an if statement in there, like in the OP.