Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions _unittests/ut_sphinxext/test_quote_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ def test_quote_show(self):
:lid: label1
:pages: 234
:year: 2018
:title1: true

this code should appear___

Expand Down
50 changes: 35 additions & 15 deletions src/pyquickhelper/sphinxext/sphinx_quote_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class QuoteNode(BaseAdmonition):
* *lid* or *label*
* *index*, additional index words beside the title and the author
* *date*, if the text was written or declared at specific date
* *title1*, by default, the author comes first, if True, the title is

Example::

Expand Down Expand Up @@ -70,6 +71,7 @@ class QuoteNode(BaseAdmonition):
'class': directives.class_option,
'index': directives.unchanged,
'date': directives.unchanged,
'title1': directives.unchanged,
}

def run(self):
Expand Down Expand Up @@ -111,6 +113,7 @@ def __(text):
source = __(self.options.get('source', "").strip())
index = __(self.options.get('index', "").strip())
date = __(self.options.get('date', "").strip())
title1 = __(self.options.get('title1', "").strip()) in ('1', 1, 'True', True, 'true')

indexes = []
if index:
Expand All @@ -123,21 +126,38 @@ def __(text):
else:
tnl = [] # pragma: no cover

if author:
tnl.append("**{0}**, ".format(author))
indexes.append(author)
if book:
tnl.append("*{0}*".format(book))
indexes.append(book)
if manga:
tnl.append("*{0}*".format(manga))
indexes.append(manga)
if show:
tnl.append("*{0}*".format(show))
indexes.append(show)
if film:
tnl.append("*{0}*".format(film))
indexes.append(film)
if title1:
if book:
tnl.append("**{0}**".format(book))
indexes.append(book)
if manga:
tnl.append("**{0}**".format(manga))
indexes.append(manga)
if show:
tnl.append("**{0}**".format(show))
indexes.append(show)
if film:
tnl.append("**{0}**".format(film))
indexes.append(film)
if author:
tnl.append("*{0}*, ".format(author))
indexes.append(author)
else:
if author:
tnl.append("**{0}**, ".format(author))
indexes.append(author)
if book:
tnl.append("*{0}*".format(book))
indexes.append(book)
if manga:
tnl.append("*{0}*".format(manga))
indexes.append(manga)
if show:
tnl.append("*{0}*".format(show))
indexes.append(show)
if film:
tnl.append("*{0}*".format(film))
indexes.append(film)
if pages:
tnl.append(", {0}".format(pages))
if date:
Expand Down