Skip to content

Commit

Permalink
Resolves #31, detect and convert inline code
Browse files Browse the repository at this point in the history
The app script API function "getTextAttributeIndices" now returns a set of text indices at which text formatting changes (including font changes)
  • Loading branch information
ggrossetie authored Sep 21, 2018
1 parent 67e62eb commit 4243882
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions app/Code.gs
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ function asciidocHandleFontStyle(text, offset, distinctContent) {
var linkURL = text.getLinkUrl(offset);
var htmlBuf = ''
// FIXME: getTextAttributeIndices doesn't split on different fonts,
// makeing this almost useless
var isCode = isTextCode(text);
// making this almost useless
var isCode = isTextCode(text, offset);
// Prefix markup
if (linkURL !== null) {
isLink = true;
Expand Down Expand Up @@ -302,10 +302,15 @@ function asciidocHandleList(child) {
}

/** Guess if the text is code by looking at the font family. */
function isTextCode(text) {
// Things will be better if Google Fonts can tell us about a font
var i, fontFamily = text.getFontFamily(), /* Now it returns a string! */
monospaceFonts = ['Consolas', 'Courier New', 'Source Code Pro'];
function isTextCode(text, offset) {
var fontFamily;
if (offset) {
fontFamily = text.getFontFamily(offset); /* Now it returns a string! */
} else {
fontFamily = text.getFontFamily(); /* Now it returns a string! */
}
// Things could be better if Google Fonts can tell us about a font
var i, monospaceFonts = ['Consolas', 'Courier New', 'Source Code Pro'];
if (fontFamily === null) {
return false; // Handle null early.. It means multiple values.
}
Expand Down

0 comments on commit 4243882

Please sign in to comment.