diff --git a/README.md b/README.md index d781a8f..872e0d4 100644 --- a/README.md +++ b/README.md @@ -14,4 +14,4 @@ 6. You will get an email at your Google Account containing the HTML output of the Google Doc with inline images. - [1]: https://raw.githubusercontent.com/oazabir/GoogleDoc2Html/master/code.js + [1]: https://github.com/trjohnst/GoogleDoc2Html/raw/master/code.js diff --git a/code.js b/code.js index 9f1fdfa..074c27b 100644 --- a/code.js +++ b/code.js @@ -99,9 +99,7 @@ function processItem(item, listCounters, images) { if (gt === DocumentApp.GlyphType.BULLET || gt === DocumentApp.GlyphType.HOLLOW_BULLET || gt === DocumentApp.GlyphType.SQUARE_BULLET) { - prefix = '
' + text + ''); + + // If someone has written [xxx] and made this whole text some special font, like superscript + // then treat it as a reference and make it superscript. + // Unfortunately in Google Docs, there's no way to detect superscript + if (partText.indexOf('[')==0 && partText[partText.length-1] == ']') { + output.push('' + partText + ''); } - else if (text.trim().indexOf('http://') == 0) { - output.push('' + text + ''); + else if (partText.trim().indexOf('http://') == 0) { + output.push('' + partText + ''); } else { - output.push(text); + output.push(partText); } - } - else { - - for (var i=0; i < indices.length; i ++) { - var partAtts = item.getAttributes(indices[i]); - var startPos = indices[i]; - var endPos = i+1 < indices.length ? indices[i+1]: text.length; - var partText = text.substring(startPos, endPos); - - Logger.log(partText); - - if (partAtts.ITALIC) { - output.push(''); - } - if (partAtts.BOLD) { - output.push(''); - } - if (partAtts.UNDERLINE) { - output.push(''); - } - - // If someone has written [xxx] and made this whole text some special font, like superscript - // then treat it as a reference and make it superscript. - // Unfortunately in Google Docs, there's no way to detect superscript - if (partText.indexOf('[')==0 && partText[partText.length-1] == ']') { - output.push('' + partText + ''); - } - else if (partText.trim().indexOf('http://') == 0) { - output.push('' + partText + ''); - } - else { - output.push(partText); - } - - if (partAtts.ITALIC) { - output.push(''); - } - if (partAtts.BOLD) { - output.push(''); - } - if (partAtts.UNDERLINE) { - output.push(''); - } - + + if (partAtts.UNDERLINE && !partAtts.LINK_URL) { + output.push(''); + } + if (partAtts.BOLD) { + output.push(''); } + if (partAtts.ITALIC) { + output.push(''); + } + if (partAtts.LINK_URL) { + output.push(''); + } + } } + function processImage(item, images, output) { images = images || [];