diff --git a/README.rst b/README.rst index aeab5b5..a5bfcbb 100644 --- a/README.rst +++ b/README.rst @@ -4,6 +4,17 @@ atsphinx-linebreak Enable line-break for everywhere. +Overview +======== + +This is Sphinx-extension to inject extra node into line-break of source (LF) when it build. +You can write source likely GitHub Flavored Markdown ("Newline" code means as "line-feed of content") by using it. + +.. note:: + + This affects to any sources including reStructuredText. + If you want to change behavior, post PR or issue into GitHub. + Getting started =============== diff --git a/src/atsphinx/linebreak/__init__.py b/src/atsphinx/linebreak/__init__.py index f0113c1..be91f1e 100644 --- a/src/atsphinx/linebreak/__init__.py +++ b/src/atsphinx/linebreak/__init__.py @@ -12,6 +12,7 @@ class line_break(nodes.Element, nodes.General): # noqa: D101 def visit_line_break(self, node: line_break): """Inject br tag (html only).""" + # NOTE: It can change inserting token by configuration. self.body.append("
") @@ -22,7 +23,10 @@ def depart_line_break(self, node: line_break): def inject_line_break(app: Sphinx, doctree: nodes.document): """Split text by line-break and inject marker node.""" + # NOTE: doctree["source"] has file path of source. + # If it want to change proc by file type, see this. for text in doctree.findall(nodes.Text): + # NOTE: This may not catch CR+LF (windows) pattern. if "\n" not in text: continue splitted = [(nodes.Text(t), line_break()) for t in text.split("\n")]