-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from ndy2/23-comment-convert
23 comment convert
- Loading branch information
Showing
17 changed files
with
145 additions
and
315 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
title: Comment | ||
--- | ||
|
||
> [!note] feature - comment | ||
> Convert `obsidian comments` to `HTML Comment Tag` | ||
> | ||
> - [obsidian comments](https://help.obsidian.md/Editing+and+formatting/Basic+formatting+syntax#Comments) | ||
> - [HTML Comment Tag](https://www.w3schools.com/tags/tag_comment.asp) | ||
## Inline Comment | ||
|
||
=== "obsidian markdown" | ||
|
||
``` | ||
This is an %%inline%% comment. | ||
``` | ||
|
||
=== "obsidian reading view" | ||
|
||
![[images/comment_1.png]] | ||
|
||
### mkdocs-material admonition | ||
|
||
=== "mkdocs-material markdown" | ||
|
||
``` | ||
This is an <!--inline--> comment. | ||
``` | ||
|
||
=== "mkdocs-material rendered" | ||
|
||
This is an %%inline%% comment. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import re | ||
|
||
from mkdocs.structure.pages import Page | ||
from overrides import override | ||
|
||
from obsidian_support.conversion.abstract_conversion import AbstractConversion, SyntaxGroup | ||
|
||
""" | ||
A strategy that convert [obsidian comments](https://help.obsidian.md/Editing+and+formatting/Basic+formatting+syntax#Comments) | ||
to [HTML Comment Tag](https://www.w3schools.com/tags/tag_comment.asp) | ||
Examples: | ||
given : `This is an %%inline%% comment.` | ||
converted : `This is an <!--inline--> comment.` | ||
""" | ||
|
||
|
||
class CommentConversion(AbstractConversion): | ||
|
||
@property | ||
@override | ||
def obsidian_regex_pattern(self): | ||
# OBSIDIAN_COMMENT_REGEX | ||
return re.compile(r"%%(?P<comment>[\S\s]*?)%%") | ||
|
||
@override | ||
def convert(self, syntax_groups: SyntaxGroup, page: Page) -> str: | ||
return self._convert_comment(*syntax_groups) | ||
|
||
def _convert_comment(self, comment): | ||
return f"<!--{comment}-->" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Comment | ||
|
||
This is an <!--inline--> comment. | ||
|
||
<!-- | ||
This is a block comment. | ||
Block comments can span multiple lines. | ||
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Comment | ||
|
||
This is an %%inline%% comment. | ||
|
||
%% | ||
This is a block comment. | ||
|
||
Block comments can span multiple lines. | ||
%% |
Oops, something went wrong.