Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE-62]: Fix closing li tag, fix nested list #63

Closed
Closed
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
14 changes: 11 additions & 3 deletions addon/html.gs
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,8 @@ html.handleListItem = function(listItem) {
// Note that ulItem, olItem are the same in HTML (<li>).
gdc.writeStringToBuffer(gdc.listPrefix + gdc.htmlMarkup.ulItem);
md.childLoop(listItem);

// Close the item of the list.
html.closeListItem();
// Check to see if we should close this list.
gdc.maybeCloseList(listItem);
};
Expand Down Expand Up @@ -528,6 +529,11 @@ html.maybeOpenList = function (listItem) {
};
// Open list and save current list type to stack.
html.openList = function() {
//Should add <li> before nested list was open
if (html.nestingLevel > 0) {
gdc.writeStringToBuffer('\n');
gdc.writeStringToBuffer(gdc.listPrefix + gdc.htmlMarkup.ulItem);
}
gdc.isList = true;
if (gdc.nestingLevel === 0) {
gdc.writeStringToBuffer('\n');
Expand All @@ -545,8 +551,6 @@ html.openList = function() {
};
// Close list and remove it's list type from the stack.
html.closeList = function() {
// Close the last item of the list.
html.closeListItem();
if (html.listStack[0] === gdc.ul) {
gdc.writeStringToBuffer(gdc.listPrefix + gdc.htmlMarkup.ulClose);
}
Expand All @@ -557,6 +561,10 @@ html.closeList = function() {
if (html.listStack.length === 0) {
gdc.isList = false;
}
// Should add </li> after nested list was closed
if (gdc.isList) {
html.closeListItem();
}
};
// But what about a table that's in a list item?
html.closeAllLists = function() {
Expand Down
66 changes: 53 additions & 13 deletions html-verification.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!----- Conversion time: 2.753 seconds.
<!----- Conversion time: 13.354 seconds.


Using this HTML file:
Expand All @@ -11,8 +11,8 @@ Using this HTML file:
Conversion notes:

* Docs to Markdown version 1.0β22
* Sun Apr 19 2020 15:10:42 GMT-0700 (PDT)
* Source doc: Docs to Markdown (GD2md-html): MASTER
* Tue Apr 28 2020 16:08:05 GMT+0500 (Yekaterinburg Standard Time)
* Source doc: Docs to HTML fix
* Tables are currently converted to HTML tables.

WARNING:
Expand Down Expand Up @@ -131,6 +131,7 @@ Here is a numbered list:
<ol>

<li>Item one.
</li>

<li>Item two.
</li>
Expand All @@ -144,20 +145,23 @@ And here is a bullet list:
<ul>

<li>A list item without any punctuation
</li>

<li>A list item with an embedded command: <code>ps aux | grep conky | grep -v grep | awk '{print $2}' | xargs kill</code>
</li>

<li>Some mixed-font code: <code>ls -l <strong><em>filename</em></strong></code>. Followed by some normal text.
</li>
</ul>
<h3 id="another-ordered-list">Another ordered list</h3>


<ol>

<li>First item
</li>

<li>Second item
</li>

<li>Third item
</li>
Expand All @@ -168,15 +172,21 @@ And here is a bullet list:
<ol>

<li>First item
</li>

<li>Second item
<li>Second item
</li>

<li>
<ol>

<li>First nested item
</li>

<li>Second nested item
</li>
</ol>
</li>

<li>Third item
</li>
Expand All @@ -190,6 +200,7 @@ You can have a code block within a list item, as long as you indent the code (i
<ul>

<li>A text item, followed by a code block that's indented and should be part of this item:
</li>



Expand All @@ -201,16 +212,19 @@ some code;

<ul>

<li>Another item.
<li>Another item.
</li>

<li>
<ul>

<li>A nested list item with a command:
</li>



<pre class="prettyprint">$ cat file | grep dog | wc

</li>

</ul>
</li>
</ul>
Expand All @@ -227,6 +241,7 @@ Note: Works for Markdown, still a known issue for HTML.
<ul>

<li>A bullet list with an additional paragraph:
</li>
<p>

This is another paragraph.
Expand All @@ -237,10 +252,14 @@ Note: Works for Markdown, still a known issue for HTML.
</p>
<ul>

<li>Another item.
<li>Another item.
</li>

<li>
<ul>

<li>A nested item.
</li>
<p>

This is a new paragraph within the nested item.
Expand All @@ -256,27 +275,38 @@ callSomeFunction();
<ul>

<li>Another list item.
</li>

<li>And another.
<li>And another.
</li>

<li>
<ul>

<li>Nested
</li>
<p>

A paragraph within a list item.
</p>
</p>

<li>
<ul>

<li>Nested
</li>
<p>

A paragraph within a list item.
</p>
</p>

<li>
<ul>

<li>Reducing the nesting level.
</li>
</ul>
</li>

<li>First-level list item.
</li>
Expand Down Expand Up @@ -544,6 +574,7 @@ Some regular URL links:
<ul>

<li><a href="http://www.google.com/">http://www.google.com/</a>
</li>

<li><a href="https://fivethirtyeight.com/">https://fivethirtyeight.com/</a>
</li>
Expand All @@ -554,6 +585,7 @@ Some links with titles:
<ul>

<li><a href="http://kottke.org/">Jason Kottke's blog</a>
</li>

<li><a href="https://beanroad.blogspot.com/">Bean Road</a>
</li>
Expand Down Expand Up @@ -697,10 +729,13 @@ FEATURE REQUEST: Angle bracket escapes:
<ul>

<li>Angle brackets: If you put angle brackets in your text: &lt; or >, we don't want that to render as an HTML tag. So, we use &amp;lt; for the opening bracket by default. However, if you select the Render HTML tags option, the opening &lt; will not be replaced.
</li>

<li>Test: it seems that loose angle brackets &lt; and > do not behave like HTML tags. But when there is no whitespace: &lt;some text>, they do behave like HTML tags. To change that behavior, we’ll need to (by default) escape the opening angle bracket and turn it into &amp;lt;.
</li>

<li>But if you really want an angle bracket while using the default setting (to insert a few HTML tags), you can escape it: <tag>, <div class=’someclass’>. Not escaped: &lt;tag>. Also not escaped: &lt;p>This is an HTML paragraph.&lt;p>
</li>

<li>Escaped: <p>This is an HTML paragraph.<p>
</li>
Expand Down Expand Up @@ -754,6 +789,7 @@ Another paragraph with <strong>some bold text</strong>.
<ol>

<li>A numbered list following a terminal subscript.
</li>

<li>Another list item.
</li>
Expand All @@ -764,10 +800,14 @@ Another paragraph with <strong>some bold text</strong>.
<ul>

<li>Current open bugs: <a href="https://github.com/evbacher/gd2md-html/issues">https://github.com/evbacher/gd2md-html/issues</a>
</li>

<li>New bug or feature request: <a href="https://github.com/evbacher/gd2md-html/issues/new">https://github.com/evbacher/gd2md-html/issues/new</a>. Thanks for helping to make Docs to Markdown better!
</li>

<li>
</li>
</ul>

<!-- Footnotes themselves at the bottom. -->

Expand All @@ -778,4 +818,4 @@ Another paragraph with <strong>some bold text</strong>.
<p>
Docs to Markdown supports footnotes!&nbsp;<a href="#fnref1" rev="footnote">&#8617;</a>

</ol></div>
</ol></div>
6 changes: 3 additions & 3 deletions markdown-verification.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!----- Conversion time: 3.177 seconds.
<!----- Conversion time: 8.324 seconds.


Using this Markdown file:
Expand All @@ -11,8 +11,8 @@ Using this Markdown file:
Conversion notes:

* Docs to Markdown version 1.0β22
* Sun Apr 19 2020 15:08:18 GMT-0700 (PDT)
* Source doc: Docs to Markdown (GD2md-html): MASTER
* Tue Apr 28 2020 16:08:28 GMT+0500 (Yekaterinburg Standard Time)
* Source doc: Docs to HTML fix
* Tables are currently converted to HTML tables.

WARNING:
Expand Down