Skip to content

Commit

Permalink
[REMOVE LATER] Trigger errors when HTML style comments are used
Browse files Browse the repository at this point in the history
  • Loading branch information
cticenhour committed Dec 19, 2024
1 parent 2bf28d3 commit 0a82fa0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions python/MooseDocs/extensions/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import re
from ..base import components, Extension
from ..tree import tokens
import logging

LOG = logging.getLogger(__name__)

def make_extension(**kwargs):
return CommentExtension(**kwargs)
Expand All @@ -25,6 +28,7 @@ def defaultConfig():
return config

def extend(self, reader, renderer):
reader.addInline(HTMLCommentBlock(), location='_begin')
reader.addInline(CommentInline(), location='_begin')
reader.addBlock(CommentBlock(), location='_begin')

Expand All @@ -37,6 +41,18 @@ def createToken(self, parent, info, page, settings):
Comment(parent, content=info['content'])
return parent

class HTMLCommentBlock(components.ReaderComponent):
"""
HTML style comments (deprecated)
"""
# TODO: Remove this in favor of !!! version
RE = re.compile(r'<!--(?P<content>.*?)-->', flags=re.UNICODE|re.MULTILINE|re.DOTALL)

def createToken(self, parent, info, page, settings):
LOG.error("Use of HTML style comments detected on page %s!", page)
Comment(parent, content=info['content'])
return parent

class CommentBlock(components.ReaderComponent):
"""
Block comments begin and end with !!! that start a line to !!! that end a line.
Expand Down

0 comments on commit 0a82fa0

Please sign in to comment.