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

Add the Date chip parsing. #105

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
19 changes: 18 additions & 1 deletion addon/gdc.gs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ gdc.config = function(config) {
if (config.suppressInfo === true) {
gdc.suppressInfo = true;
}
if (config.formatISODate === true) {
gdc.formatISODate = true;
}
};

// Setup for each conversion run.
Expand Down Expand Up @@ -371,7 +374,9 @@ var
INLINE_DRAWING = DocumentApp.ElementType.INLINE_DRAWING,
INLINE_IMAGE = DocumentApp.ElementType.INLINE_IMAGE,
UNSUPPORTED = DocumentApp.ElementType.UNSUPPORTED,
EQUATION = DocumentApp.ElementType.EQUATION;
EQUATION = DocumentApp.ElementType.EQUATION,

DATE = DocumentApp.ElementType.DATE;

// Heading links and ids gleaned from the TOC, if present.
gdc.hasToc = false;
Expand Down Expand Up @@ -911,6 +916,15 @@ gdc.handleEquation = function() {
gdc.alert('equation: use MathJax/LaTeX if your publishing platform supports it.');
};

gdc.handleDate = function(child) {
let d = child.asDate();
if (gdc.formatISODate) {
gdc.writeStringToBuffer(d.getTimestamp().toISOString().split("T")[0]);
} else {
gdc.writeStringToBuffer(d.getDisplayText());
}
}

// Warns/alerts that there are some inline drawings -- no API for that yet :( .
gdc.handleInlineDrawing = function() {
if (!gdc.handledInlineDrawing) {
Expand Down Expand Up @@ -1726,6 +1740,9 @@ md.handleChildElement = function(child) {
case EQUATION:
gdc.handleEquation();
break;
case DATE:
gdc.handleDate(child);
break;
case UNSUPPORTED:
gdc.log('child element: UNSUPPORTED');
break;
Expand Down
9 changes: 9 additions & 0 deletions addon/sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@
<input type="checkbox" id="suppress_info">
Suppress top comment
</label>
<br>
<label>
<input type="checkbox" id="format_iso_date">
Format dates as YYYY-MM-DD
</label>

<!-- Docs, bug link. -->
<br>
Expand Down Expand Up @@ -175,6 +180,7 @@
config.wrapHTML = false;
config.renderHTMLTags = false;
config.suppressInfo= false;
config.formatISODate = false;

// Config settings from UI.
if (document.getElementById('demote_headings').checked) {
Expand All @@ -192,6 +198,9 @@
if (document.getElementById('suppress_info').checked) {
config.suppressInfo = true;
}
if (document.getElementById('format_iso_date').checked) {
config.formatISODate = true;
}
};

// Make the calls to the server, and send some callbacks for
Expand Down
21 changes: 9 additions & 12 deletions html-verification.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<!-- Output copied to clipboard! -->

<!-----
NEW: Check the "Suppress top comment" option to remove this info from the output.

Conversion time: 1.74 seconds.
Conversion time: 9.863 seconds.


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

* Docs to Markdown version 1.0β31
* Thu Aug 26 2021 12:22:58 GMT-0700 (PDT)
* Source doc: MAIN: Docs to Markdown (GD2md-html)
* Sun Mar 20 2022 17:10:44 GMT-0400 (Eastern Daylight Time)
* Source doc: Copy of dev verification doc (1.0β27 base): Docs to Markdown (gd2md-html)
* Tables are currently converted to HTML tables.

WARNING:
Expand Down Expand Up @@ -759,15 +761,11 @@ Another paragraph with <strong>some bold text</strong>.
<li>Another list item.
</li>
</ol>
<h2>Horizontal rules</h2>
<h2>Chips</h2>


<p>
This is a horizontal rule:
</p>
<hr>
<p>
This is a regular paragraph.
This is a date: Mar 20, 2022.
</p>
<h2 id="bugs">Bugs</h2>

Expand All @@ -777,11 +775,10 @@ This is a regular paragraph.
<li>Current open bugs: <a href="https://github.com/evbacher/gd2md-html/issues">https://github.com/evbacher/gd2md-html/issues</a>

<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>
</ul>
<p>
This document ends with a regular paragraph.
</p>

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

Expand Down
21 changes: 8 additions & 13 deletions markdown-verification.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<!-- Output copied to clipboard! -->

<!-----
NEW: Check the "Suppress top comment" option to remove this info from the output.

Conversion time: 1.471 seconds.
Conversion time: 8.742 seconds.


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

* Docs to Markdown version 1.0β31
* Thu Aug 26 2021 12:21:46 GMT-0700 (PDT)
* Source doc: MAIN: Docs to Markdown (GD2md-html)
* Sun Mar 20 2022 17:08:39 GMT-0400 (Eastern Daylight Time)
* Source doc: Copy of dev verification doc (1.0β27 base): Docs to Markdown (gd2md-html)
* Tables are currently converted to HTML tables.

WARNING:
Expand Down Expand Up @@ -607,15 +609,10 @@ Another paragraph with **some bold text**.
1. A numbered list following a terminal subscript.
2. Another list item.

<h2>Horizontal rules</h2>


This is a horizontal rule:
<h2>Chips</h2>


---

This is a regular paragraph.
This is a date: Mar 20, 2022.

<h2 id="bugs">Bugs</h2>

Expand All @@ -624,9 +621,7 @@ This is a regular paragraph.

* Current open bugs: [https://github.com/evbacher/gd2md-html/issues](https://github.com/evbacher/gd2md-html/issues)
* New bug or feature request: [https://github.com/evbacher/gd2md-html/issues/new](https://github.com/evbacher/gd2md-html/issues/new). Thanks for helping to make Docs to Markdown better!

This document ends with a regular paragraph.

*

<!-- Footnotes themselves at the bottom. -->
## Notes
Expand Down