Add underline command in markdown
This commit is contained in:
parent
4bd583f92f
commit
577acbd9f5
|
@ -18,4 +18,4 @@
|
||||||
along with Dynastie. If not, see <http://www.gnu.org/licenses/>.
|
along with Dynastie. If not, see <http://www.gnu.org/licenses/>.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__all__ = ["generator", "index", "post", "category", "tag", "archive", "rss", "atom", "all_posts"]
|
__all__ = ["generator", "index", "post", "category", "tag", "archive", "rss", "atom", "all_posts", "ljdc"]
|
||||||
|
|
|
@ -205,15 +205,20 @@ class DynastieGenerator:
|
||||||
return root
|
return root
|
||||||
filename = base.getAttribute('file')
|
filename = base.getAttribute('file')
|
||||||
|
|
||||||
if not base.hasAttribute('block'):
|
|
||||||
self.addError('No \'block\' attribute defined')
|
|
||||||
return root
|
|
||||||
target_block = base.getAttribute('block')
|
|
||||||
|
|
||||||
if not os.path.exists(src + '/' + filename):
|
if not os.path.exists(src + '/' + filename):
|
||||||
self.addError('Base ' + filename + ' doesn\'t exists')
|
self.addError('Base ' + filename + ' doesn\'t exists')
|
||||||
return root
|
return root
|
||||||
|
|
||||||
|
target_blocks = base.getElementsByTagNameNS(self.URI, 'block')
|
||||||
|
if len(target_blocks) == 0:
|
||||||
|
self.addError('No \'block\' defined in ' + src + '/' + filename)
|
||||||
|
return root
|
||||||
|
|
||||||
|
for target_block in target_blocks:
|
||||||
|
if not target_block.hasAttribute('name'):
|
||||||
|
self.addError('Every block must have a name in ' + src + '/' + filename)
|
||||||
|
return root
|
||||||
|
|
||||||
dom2 = root
|
dom2 = root
|
||||||
try:
|
try:
|
||||||
dom2 = parse(src + '/' + filename)
|
dom2 = parse(src + '/' + filename)
|
||||||
|
@ -225,19 +230,22 @@ class DynastieGenerator:
|
||||||
block_found = False
|
block_found = False
|
||||||
for block in blocks:
|
for block in blocks:
|
||||||
if not block.hasAttribute('name'):
|
if not block.hasAttribute('name'):
|
||||||
self.addError('block has no attribute \'name\' in ' + filename)
|
self.addError('block has no attribute \'name\' in ' + src + '/' + filename)
|
||||||
return root
|
return root
|
||||||
blockname = block.getAttribute('name')
|
blockname = block.getAttribute('name')
|
||||||
if blockname != target_block:
|
for target_block in target_blocks:
|
||||||
continue
|
|
||||||
|
if blockname != target_block.getAttribute('name'):
|
||||||
|
continue
|
||||||
|
|
||||||
for child in root.childNodes:
|
for child in target_block.childNodes:
|
||||||
block.parentNode.appendChild(child.cloneNode(True))
|
block.parentNode.appendChild(child.cloneNode(True))
|
||||||
|
block_found = True
|
||||||
|
break
|
||||||
block.parentNode.removeChild(block)
|
block.parentNode.removeChild(block)
|
||||||
block_found = True
|
|
||||||
|
|
||||||
if not block_found:
|
if not block_found:
|
||||||
self.addError('Block ' + target_block + ' not found in ' + src + '/' + filename)
|
self.addError('Any block found in ' + src + '/' + filename)
|
||||||
return root
|
return root
|
||||||
|
|
||||||
root = dom2.firstChild
|
root = dom2.firstChild
|
||||||
|
|
|
@ -1614,16 +1614,19 @@ class Markdown(object):
|
||||||
_code_friendly_strong_re = re.compile(r"\*\*(?=\S)(.+?[*_]*)(?<=\S)\*\*", re.S)
|
_code_friendly_strong_re = re.compile(r"\*\*(?=\S)(.+?[*_]*)(?<=\S)\*\*", re.S)
|
||||||
_code_friendly_em_re = re.compile(r"\*(?=\S)(.+?)(?<=\S)\*", re.S)
|
_code_friendly_em_re = re.compile(r"\*(?=\S)(.+?)(?<=\S)\*", re.S)
|
||||||
_code_friendly_line_re = re.compile(r"\~\~(?=\S)(.+?)(?<=\S)\~\~", re.S)
|
_code_friendly_line_re = re.compile(r"\~\~(?=\S)(.+?)(?<=\S)\~\~", re.S)
|
||||||
|
_code_friendly_underline_re = re.compile(r"\~(?=\S)(.+?)(?<=\S)\~", re.S)
|
||||||
def _do_italics_and_bold(self, text):
|
def _do_italics_and_bold(self, text):
|
||||||
# <strong> must go first:
|
# <strong> must go first:
|
||||||
if "code-friendly" in self.extras:
|
if "code-friendly" in self.extras:
|
||||||
text = self._code_friendly_strong_re.sub(r"<strong>\1</strong>", text)
|
text = self._code_friendly_strong_re.sub(r"<strong>\1</strong>", text)
|
||||||
text = self._code_friendly_em_re.sub(r"<em>\1</em>", text)
|
text = self._code_friendly_em_re.sub(r"<em>\1</em>", text)
|
||||||
text = self._code_friendly_line_re.sub(r"<span style='text-decoration:line-through'>\1</span>", text)
|
text = self._code_friendly_line_re.sub(r"<span style='text-decoration:line-through'>\1</span>", text)
|
||||||
|
text = self._code_friendly_underline_re.sub(r"<span style='text-decoration:underline'>\1</span>", text)
|
||||||
else:
|
else:
|
||||||
text = self._strong_re.sub(r"<strong>\2</strong>", text)
|
text = self._strong_re.sub(r"<strong>\2</strong>", text)
|
||||||
text = self._em_re.sub(r"<em>\2</em>", text)
|
text = self._em_re.sub(r"<em>\2</em>", text)
|
||||||
text = self._code_friendly_line_re.sub(r"<span style='text-decoration:line-through'>\1</span>", text)
|
text = self._code_friendly_line_re.sub(r"<span style='text-decoration:line-through'>\1</span>", text)
|
||||||
|
text = self._code_friendly_underline_re.sub(r"<span style='text-decoration:underline'>\1</span>", text)
|
||||||
return text
|
return text
|
||||||
|
|
||||||
# "smarty-pants" extra: Very liberal in interpreting a single prime as an
|
# "smarty-pants" extra: Very liberal in interpreting a single prime as an
|
||||||
|
|
|
@ -46,6 +46,7 @@ Available tags:
|
||||||
<pre style="display:inline">_italic_</pre> <span style="font-style:italic">italic</span><br/>
|
<pre style="display:inline">_italic_</pre> <span style="font-style:italic">italic</span><br/>
|
||||||
<pre style="display:inline">**bold**</pre> <span style="font-weight:bold">bold</span><br/>
|
<pre style="display:inline">**bold**</pre> <span style="font-weight:bold">bold</span><br/>
|
||||||
<pre style="display:inline">~~line through~~</pre> <span style="text-decoration:line-through">line through</span><br/>
|
<pre style="display:inline">~~line through~~</pre> <span style="text-decoration:line-through">line through</span><br/>
|
||||||
|
<pre style="display:inline">~underline~</pre> <span style="text-decoration:underline">underline</span><br/>
|
||||||
<pre style="display:inline">>Citation</pre><br/>
|
<pre style="display:inline">>Citation</pre><br/>
|
||||||
<pre>
|
<pre>
|
||||||
* Unordered list
|
* Unordered list
|
||||||
|
|
|
@ -58,6 +58,7 @@ Available tags:
|
||||||
<pre style="display:inline">_italic_</pre> <span style="font-style:italic">italic</span><br/>
|
<pre style="display:inline">_italic_</pre> <span style="font-style:italic">italic</span><br/>
|
||||||
<pre style="display:inline">**bold**</pre> <span style="font-weight:bold">bold</span><br/>
|
<pre style="display:inline">**bold**</pre> <span style="font-weight:bold">bold</span><br/>
|
||||||
<pre style="display:inline">~~line through~~</pre> <span style="text-decoration:line-through">line through</span><br/>
|
<pre style="display:inline">~~line through~~</pre> <span style="text-decoration:line-through">line through</span><br/>
|
||||||
|
<pre style="display:inline">~underline~</pre> <span style="text-decoration:underline">underline</span><br/>
|
||||||
<pre style="display:inline">>Citation</pre><br/>
|
<pre style="display:inline">>Citation</pre><br/>
|
||||||
<pre>
|
<pre>
|
||||||
* Unordered list
|
* Unordered list
|
||||||
|
|
|
@ -19,6 +19,10 @@
|
||||||
<br/><br/>
|
<br/><br/>
|
||||||
{% endautoescape %}
|
{% endautoescape %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<form action="/blog/search/{{ blog.id }}" method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
<input name="text"/><input type="submit" name="search" value="Search" />
|
||||||
|
</form>
|
||||||
{% if posts|length == 0 %}
|
{% if posts|length == 0 %}
|
||||||
<br/><br/>
|
<br/><br/>
|
||||||
<b>Any post available</b><br/><br/>
|
<b>Any post available</b><br/><br/>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user