Skip to content

Commit efe54bb

Browse files
committed
value attribute for <li> tag
With the `<li>` tag in HTML it is possible to have a `value=` attribute, this was only working for the HTML output, but has now been added to other output formats as well. Also fixed small counting issue in case we have more than the supported number of levels. (For docbook there is no solution yet)
1 parent 2346371 commit efe54bb

File tree

9 files changed

+114
-14
lines changed

9 files changed

+114
-14
lines changed

src/latexdocvisitor.cpp

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ const int maxLevels=5;
4343
static const char *secLabels[maxLevels] =
4444
{ "doxysection","doxysubsection","doxysubsubsection","doxyparagraph","doxysubparagraph" };
4545

46+
LatexListItemInfo latex_listItemInfo[latex_maxIndentLevels];
47+
4648
static const char *getSectionName(int level)
4749
{
4850
static bool compactLatex = Config_getBool(COMPACT_LATEX);
@@ -180,7 +182,7 @@ LatexDocVisitor::LatexDocVisitor(TextStream &t,LatexCodeGenerator &ci,
180182
const QCString &langExt,bool insideTabbing)
181183
: DocVisitor(DocVisitor_Latex), m_t(t), m_ci(ci), m_insidePre(FALSE),
182184
m_insideItem(FALSE), m_hide(FALSE), m_hideCaption(FALSE), m_insideTabbing(insideTabbing),
183-
m_langExt(langExt)
185+
m_indentLevel(1), m_langExt(langExt)
184186
{
185187
}
186188

@@ -668,9 +670,11 @@ void LatexDocVisitor::visitPre(DocAutoList *l)
668670
if (l->isEnumList())
669671
{
670672
m_t << "\n\\begin{DoxyEnumerate}";
673+
latex_listItemInfo[m_indentLevel].isEnum = true;
671674
}
672675
else
673676
{
677+
latex_listItemInfo[m_indentLevel].isEnum = false;
674678
m_t << "\n\\begin{DoxyItemize}";
675679
}
676680
}
@@ -692,10 +696,12 @@ void LatexDocVisitor::visitPre(DocAutoListItem *)
692696
{
693697
if (m_hide) return;
694698
m_t << "\n\\item ";
699+
incIndentLevel();
695700
}
696701

697702
void LatexDocVisitor::visitPost(DocAutoListItem *)
698703
{
704+
decIndentLevel();
699705
}
700706

701707
void LatexDocVisitor::visitPre(DocPara *)
@@ -712,12 +718,14 @@ void LatexDocVisitor::visitPost(DocPara *p)
712718
) m_t << "\n\n";
713719
}
714720

715-
void LatexDocVisitor::visitPre(DocRoot *)
721+
void LatexDocVisitor::visitPre(DocRoot *r)
716722
{
723+
//if (r->indent()) incIndentLevel();
717724
}
718725

719-
void LatexDocVisitor::visitPost(DocRoot *)
726+
void LatexDocVisitor::visitPost(DocRoot *r)
720727
{
728+
//if (r->indent()) decIndentLevel();
721729
}
722730

723731
void LatexDocVisitor::visitPre(DocSimpleSect *s)
@@ -797,6 +805,7 @@ void LatexDocVisitor::visitPre(DocSimpleSect *s)
797805
// special case 1: user defined title
798806
if (s->type()!=DocSimpleSect::User && s->type()!=DocSimpleSect::Rcs)
799807
{
808+
incIndentLevel();
800809
m_t << "}\n";
801810
}
802811
else
@@ -864,6 +873,7 @@ void LatexDocVisitor::visitPost(DocSimpleSect *s)
864873
default:
865874
break;
866875
}
876+
decIndentLevel();
867877
}
868878

869879
void LatexDocVisitor::visitPre(DocTitle *)
@@ -881,6 +891,7 @@ void LatexDocVisitor::visitPre(DocSimpleList *)
881891
{
882892
if (m_hide) return;
883893
m_t << "\\begin{DoxyItemize}\n";
894+
latex_listItemInfo[m_indentLevel].isEnum = false;
884895
}
885896

886897
void LatexDocVisitor::visitPost(DocSimpleList *)
@@ -893,10 +904,12 @@ void LatexDocVisitor::visitPre(DocSimpleListItem *)
893904
{
894905
if (m_hide) return;
895906
m_t << "\\item ";
907+
incIndentLevel();
896908
}
897909

898910
void LatexDocVisitor::visitPost(DocSimpleListItem *)
899911
{
912+
decIndentLevel();
900913
}
901914

902915
void LatexDocVisitor::visitPre(DocSection *s)
@@ -918,6 +931,7 @@ void LatexDocVisitor::visitPost(DocSection *)
918931
void LatexDocVisitor::visitPre(DocHtmlList *s)
919932
{
920933
if (m_hide) return;
934+
latex_listItemInfo[m_indentLevel].isEnum = s->type()==DocHtmlList::Ordered;
921935
if (s->type()==DocHtmlList::Ordered)
922936
{
923937
bool first = true;
@@ -960,7 +974,9 @@ void LatexDocVisitor::visitPre(DocHtmlList *s)
960974
else if (opt.name=="start")
961975
{
962976
m_t << (first ? "[": ",");
963-
m_t << "start=" << opt.value;
977+
bool ok;
978+
int val = opt.value.toInt(&ok);
979+
if (ok) m_t << "start=" << opt.value;
964980
first = false;
965981
}
966982
}
@@ -979,14 +995,31 @@ void LatexDocVisitor::visitPost(DocHtmlList *s)
979995
m_t << "\n\\end{DoxyItemize}";
980996
}
981997

982-
void LatexDocVisitor::visitPre(DocHtmlListItem *)
998+
void LatexDocVisitor::visitPre(DocHtmlListItem *l)
983999
{
9841000
if (m_hide) return;
1001+
if (latex_listItemInfo[m_indentLevel].isEnum)
1002+
{
1003+
for (const auto &opt : l->attribs())
1004+
{
1005+
if (opt.name=="value")
1006+
{
1007+
bool ok;
1008+
int val = opt.value.toInt(&ok);
1009+
if (ok)
1010+
{
1011+
m_t << "\n\\setcounter{enum"<< integerToRoman(m_indentLevel,false).data() << "}{" << val - 1 << "}";
1012+
}
1013+
}
1014+
}
1015+
}
9851016
m_t << "\n\\item ";
1017+
incIndentLevel();
9861018
}
9871019

9881020
void LatexDocVisitor::visitPost(DocHtmlListItem *)
9891021
{
1022+
decIndentLevel();
9901023
}
9911024

9921025
//void LatexDocVisitor::visitPre(DocHtmlPre *)
@@ -1077,10 +1110,12 @@ void LatexDocVisitor::visitPost(DocHtmlDescTitle *)
10771110

10781111
void LatexDocVisitor::visitPre(DocHtmlDescData *)
10791112
{
1113+
incIndentLevel();
10801114
}
10811115

10821116
void LatexDocVisitor::visitPost(DocHtmlDescData *)
10831117
{
1118+
decIndentLevel();
10841119
}
10851120

10861121
static bool tableIsNested(const DocNode *n)
@@ -1577,11 +1612,13 @@ void LatexDocVisitor::visitPre(DocSecRefList *)
15771612
m_t << "\\footnotesize\n";
15781613
m_t << "\\begin{multicols}{2}\n";
15791614
m_t << "\\begin{DoxyCompactList}\n";
1615+
incIndentLevel();
15801616
}
15811617

15821618
void LatexDocVisitor::visitPost(DocSecRefList *)
15831619
{
15841620
if (m_hide) return;
1621+
decIndentLevel();
15851622
m_t << "\\end{DoxyCompactList}\n";
15861623
m_t << "\\end{multicols}\n";
15871624
m_t << "\\normalsize\n";
@@ -1616,6 +1653,7 @@ void LatexDocVisitor::visitPre(DocParamSect *s)
16161653
break;
16171654
default:
16181655
ASSERT(0);
1656+
incIndentLevel();
16191657
}
16201658
m_t << "}\n";
16211659
}
@@ -1640,6 +1678,7 @@ void LatexDocVisitor::visitPost(DocParamSect *s)
16401678
break;
16411679
default:
16421680
ASSERT(0);
1681+
decIndentLevel();
16431682
}
16441683
}
16451684

@@ -1752,6 +1791,7 @@ void LatexDocVisitor::visitPre(DocXRefItem *x)
17521791
static bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS);
17531792
if (m_hide) return;
17541793
if (x->title().isEmpty()) return;
1794+
incIndentLevel();
17551795
m_t << "\\begin{DoxyRefDesc}{";
17561796
filter(x->title());
17571797
m_t << "}\n";
@@ -1779,6 +1819,7 @@ void LatexDocVisitor::visitPost(DocXRefItem *x)
17791819
{
17801820
if (m_hide) return;
17811821
if (x->title().isEmpty()) return;
1822+
decIndentLevel();
17821823
m_t << "\\end{DoxyRefDesc}\n";
17831824
}
17841825

@@ -1806,12 +1847,14 @@ void LatexDocVisitor::visitPre(DocHtmlBlockQuote *)
18061847
{
18071848
if (m_hide) return;
18081849
m_t << "\\begin{quote}\n";
1850+
incIndentLevel();
18091851
}
18101852

18111853
void LatexDocVisitor::visitPost(DocHtmlBlockQuote *)
18121854
{
18131855
if (m_hide) return;
18141856
m_t << "\\end{quote}\n";
1857+
decIndentLevel();
18151858
}
18161859

18171860
void LatexDocVisitor::visitPre(DocVhdlFlow *)

src/latexdocvisitor.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@
2424
class LatexCodeGenerator;
2525
class TextStream;
2626

27+
28+
struct LatexListItemInfo
29+
{
30+
bool isEnum;
31+
};
32+
33+
const int latex_maxIndentLevels = 5;
34+
35+
extern LatexListItemInfo latex_listItemInfo[latex_maxIndentLevels];
36+
2737
/*! @brief Concrete visitor implementation for LaTeX output. */
2838
class LatexDocVisitor : public DocVisitor
2939
{
@@ -176,6 +186,9 @@ class LatexDocVisitor : public DocVisitor
176186
void writeDiaFile(const QCString &fileName, DocVerbatim *s);
177187
void writePlantUMLFile(const QCString &fileName, DocVerbatim *s);
178188

189+
void incIndentLevel() {if (m_indentLevel<latex_maxIndentLevels-1) m_indentLevel++; else m_extra++;}
190+
void decIndentLevel() {if (m_extra) {m_extra--;} else if (m_indentLevel>0) m_indentLevel--;}
191+
179192
//--------------------------------------
180193
// state variables
181194
//--------------------------------------
@@ -187,7 +200,9 @@ class LatexDocVisitor : public DocVisitor
187200
bool m_hide;
188201
bool m_hideCaption;
189202
bool m_insideTabbing;
203+
int m_indentLevel;
190204
QCString m_langExt;
205+
int m_extra=0;
191206

192207
struct TableState
193208
{
@@ -263,5 +278,4 @@ class LatexDocVisitor : public DocVisitor
263278
}
264279

265280
};
266-
267281
#endif

src/mandocvisitor.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,15 @@ void ManDocVisitor::visitPre(DocHtmlListItem *li)
685685
m_t << ".IP \"" << ws;
686686
if (((DocHtmlList *)li->parent())->type()==DocHtmlList::Ordered)
687687
{
688+
for (const auto &opt : li->attribs())
689+
{
690+
if (opt.name=="value")
691+
{
692+
bool ok;
693+
int val = opt.value.toInt(&ok);
694+
if (ok) man_listItemInfo[m_indent].number = val;
695+
}
696+
}
688697
switch (man_listItemInfo[m_indent].type)
689698
{
690699
case '1':

src/perlmodgen.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,17 @@ void PerlModDocVisitor::visitPost(DocHtmlList *)
950950
closeItem();
951951
}
952952

953-
void PerlModDocVisitor::visitPre(DocHtmlListItem *) { openSubBlock(); }
953+
void PerlModDocVisitor::visitPre(DocHtmlListItem *l)
954+
{
955+
for (const auto &opt : l->attribs())
956+
{
957+
if (opt.name=="value")
958+
{
959+
m_output.addFieldQuotedString("item_value", qPrint(opt.value));
960+
}
961+
}
962+
openSubBlock();
963+
}
954964
void PerlModDocVisitor::visitPost(DocHtmlListItem *) { closeSubBlock(); }
955965

956966
//void PerlModDocVisitor::visitPre(DocHtmlPre *)

src/printdocvisitor.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,10 +402,15 @@ class PrintDocVisitor : public DocVisitor
402402
indent_post();
403403
if (s->type()==DocHtmlList::Ordered) printf("</ol>\n"); else printf("</ul>\n");
404404
}
405-
void visitPre(DocHtmlListItem *)
405+
void visitPre(DocHtmlListItem *s)
406406
{
407407
indent_pre();
408-
printf("<li>\n");
408+
printf("<li");
409+
for (const auto &opt : s->attribs())
410+
{
411+
printf(" %s=\"%s\"",qPrint(opt.name),qPrint(opt.value));
412+
}
413+
printf(">\n");
409414
}
410415
void visitPost(DocHtmlListItem *)
411416
{

src/rtfdocvisitor.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ QCString RTFDocVisitor::getStyle(const QCString &name)
7171

7272
void RTFDocVisitor::incIndentLevel()
7373
{
74-
if (m_indentLevel<rtf_maxIndentLevels-1) m_indentLevel++;
74+
if (m_indentLevel<rtf_maxIndentLevels-1) m_indentLevel++; else m_extra++;
7575
}
7676

7777
void RTFDocVisitor::decIndentLevel()
7878
{
79-
if (m_indentLevel>0) m_indentLevel--;
79+
if (m_extra) m_extra--; else if (m_indentLevel>0) m_indentLevel--;
8080
}
8181

8282
//--------------------------------------
@@ -918,14 +918,23 @@ void RTFDocVisitor::visitPost(DocHtmlList *)
918918
m_lastIsPara=TRUE;
919919
}
920920

921-
void RTFDocVisitor::visitPre(DocHtmlListItem *)
921+
void RTFDocVisitor::visitPre(DocHtmlListItem *l)
922922
{
923923
if (m_hide) return;
924924
DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocHtmlListItem)}\n");
925925
m_t << "\\par\n";
926926
m_t << rtf_Style_Reset;
927927
if (rtf_listItemInfo[m_indentLevel].isEnum)
928928
{
929+
for (const auto &opt : l->attribs())
930+
{
931+
if (opt.name=="value")
932+
{
933+
bool ok;
934+
int val = opt.value.toInt(&ok);
935+
if (ok) rtf_listItemInfo[m_indentLevel].number = val;
936+
}
937+
}
929938
m_t << getStyle("ListEnum") << "\n";
930939
switch (rtf_listItemInfo[m_indentLevel].type)
931940
{

src/rtfdocvisitor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ class RTFDocVisitor : public DocVisitor
170170
int m_indentLevel;
171171
bool m_lastIsPara;
172172
QCString m_langExt;
173+
int m_extra = 0;;
173174
};
174175

175176
#endif

src/xmldocvisitor.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,10 +731,18 @@ void XmlDocVisitor::visitPost(DocHtmlList *s)
731731
m_t << "</itemizedlist>\n";
732732
}
733733

734-
void XmlDocVisitor::visitPre(DocHtmlListItem *)
734+
void XmlDocVisitor::visitPre(DocHtmlListItem *l)
735735
{
736736
if (m_hide) return;
737-
m_t << "<listitem>\n";
737+
m_t << "<listitem";
738+
for (const auto &opt : l->attribs())
739+
{
740+
if (opt.name=="value")
741+
{
742+
m_t << " " << opt.name << "=\"" << opt.value << "\"";
743+
}
744+
}
745+
m_t << ">\n";
738746
}
739747

740748
void XmlDocVisitor::visitPost(DocHtmlListItem *)

templates/xml/compound.xsd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@
520520
<xsd:sequence>
521521
<xsd:element name="para" type="docParaType" minOccurs="0" maxOccurs="unbounded" />
522522
</xsd:sequence>
523+
<xsd:attribute name="value" type="xsd:integer" use="optional"/>
523524
</xsd:complexType>
524525

525526
<xsd:complexType name="docSimpleSectType">

0 commit comments

Comments
 (0)