您好,我用您的工具发现图片链接没有准确修改,大概像这样吧,网址没有更正成markdown格式的,可以帮忙修复一下吗
右击动作图标 - 调试运行,发一下调试日志看看。
对了,复制的内容是富文本吗?如果是纯文本的话不会起作用的。
Win-10.0.19044.0 Quicker-1.26.21.0 动作ID:2f2054e0-9576-475b-a90e-af08fa6694b7 来源动作:e14d563e-dd33-4fdd-f47e-08d8f95763cd v2
这个是e
我给您发了复制文档和截图,希望能对您有用,谢谢
不好意思,因为你这几条回复回的其实是你自己的帖子,所以我一直没收到通知,直到现在才看到😂
看了一下调试日志,是没连接上扩展程序,所以动作调用了 Quicker 的公共API来转换的。
但这个 API 好像不支持嵌套在 a 标签里的 img,所以没能正确处理。
试了一下,Turndown 的转换结果是正常的。
API 的问题我已经向 @CL 反馈了,建议现在先安装 Quicker 扩展,用 Turndown 顶着。
右击动作图标 - 调试运行,发一下调试日志看看。
对了,复制的内容是富文本吗?如果是纯文本的话不会起作用的。
Win-10.0.19044.0 Quicker-1.26.21.0 动作ID:2f2054e0-9576-475b-a90e-af08fa6694b7 来源动作:e14d563e-dd33-4fdd-f47e-08d8f95763cd v2
原链接如下。
turndown:https://github.com/domchristie/turndown
turndown-plugin-gfm:https://github.com/domchristie/turndown-plugin-gfm
Quicker 工具API:https://github.com/cuiliang/tools.getquicker.cn
var TurndownService = (function () {\r\n
'use strict';\r\n
\r\n
function extend (destination) {\r\n
for (var i = 1; i < arguments.length; i++) {\r\n
var source = arguments[i];\r\n
for (var key in source) {\r\n
if (source.hasOwnProperty(key)) destination[key] = source[key];\r\n
}\r\n
}\r\n
return destination\r\n
}\r\n
\r\n
function repeat (character, count) {\r\n
return Array(count + 1).join(character)\r\n
}\r\n
\r\n
var blockElements = [\r\n
'ADDRESS', 'ARTICLE', 'ASIDE', 'AUDIO', 'BLOCKQUOTE', 'BODY', 'CANVAS',\r\n
'CENTER', 'DD', 'DIR', 'DIV', 'DL', 'DT', 'FIELDSET', 'FIGCAPTION', 'FIGURE',\r\n
'FOOTER', 'FORM', 'FRAMESET', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'HEADER',\r\n
'HGROUP', 'HR', 'HTML', 'ISINDEX', 'LI', 'MAIN', 'MENU', 'NAV', 'NOFRAMES',\r\n
'NOSCRIPT', 'OL', 'OUTPUT', 'P', 'PRE', 'SECTION', 'TABLE', 'TBODY', 'TD',\r\n
'TFOOT', 'TH', 'THEAD', 'TR', 'UL'\r\n
];\r\n
\r\n
function isBlock (node) {\r\n
return is(node, blockElements)\r\n
}\r\n
\r\n
var voidElements = [\r\n
'AREA', 'BASE', 'BR', 'COL', 'COMMAND', 'EMBED', 'HR', 'IMG', 'INPUT',\r\n
'KEYGEN', 'LINK', 'META', 'PARAM', 'SOURCE', 'TRACK', 'WBR'\r\n
];\r\n
\r\n
function isVoid (node) {\r\n
return is(node, voidElements)\r\n
}\r\n
\r\n
function hasVoid (node) {\r\n
return has(node, voidElements)\r\n
}\r\n
\r\n
var meaningfulWhenBlankElements = [\r\n
'A', 'TABLE', 'THEAD', 'TBODY', 'TFOOT', 'TH', 'TD', 'IFRAME', 'SCRIPT',\r\n
'AUDIO', 'VIDEO'\r\n
];\r\n
\r\n
function isMeaningfulWhenBlank (node) {\r\n
return is(node, meaningfulWhenBlankElements)\r\n
}\r\n
\r\n
function hasMeaningfulWhenBlank (node) {\r\n
return has(node, meaningfulWhenBlankElements)\r\n
}\r\n
\r\n
function is (node, tagNames) {\r\n
return tagNames.indexOf(node.nodeName) >= 0\r\n
}\r\n
\r\n
function has (node, tagNames) {\r\n
return (\r\n
node.getElementsByTagName &&\r\n
tagNames.some(function (tagName) {\r\n
return node.getElementsByTagName(tagName).length\r\n
})\r\n
)\r\n
}\r\n
\r\n
var rules = {};\r\n
\r\n
rules.paragraph = {\r\n
filter: 'p',\r\n
\r\n
replacement: function (content) {\r\n
return '\n\n' + content + '\n\n'\r\n
}\r\n
};\r\n
\r\n
rules.lineBreak = {\r\n
filter: 'br',\r\n
\r\n
replacement: function (content, node, options) {\r\n
return options.br + '\n'\r\n
}\r\n
};\r\n
\r\n
rules.heading = {\r\n
filter: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'],\r\n
\r\n
replacement: function (content, node, options) {\r\n
var hLevel = Number(node.nodeName.charAt(1));\r\n
\r\n
if (options.headingStyle === 'setext' && hLevel < 3) {\r\n
var underline = repeat((hLevel === 1 ? '=' : '-'), content.length);\r\n
return (\r\n
'\n\n' + content + '\n' + underline + '\n\n'\r\n
)\r\n
} else {\r\n
return '\n\n' + repeat('#', hLevel) + ' ' + content + '\n\n'\r\n
}\r\n
}\r\n
};\r\n
\r\n
rules.blockquote = {\r\n
filter: 'blockquote',\r\n
\r\n
replacement: function (content) {\r\n
content = content.replace(/^\n+|\n+$/g, '');\r\n
content = content.replace(/^/gm, '> ');\r\n
return '\n\n' + content + '\n\n'\r\n
}\r\n
};\r\n
\r\n
rules.list = {\r\n
filter: ['ul', 'ol'],\r\n
\r\n
replacement: function (content, node) {\r\n
var parent = node.parentNode;\r\n
if (parent.nodeName === 'LI' && parent.lastElementChild === node) {\r\n
return '\n' + content\r\n
} else {\r\n
return '\n\n' + content + '\n\n'\r\n
}\r\n
}\r\n
};\r\n
\r\n
rules.listItem = {\r\n
filter: 'li',\r\n
\r\n
replacement: function (content, node, options) {\r\n
content = content\r\n
.replace(/^\n+/, '') // remove leading newlines\r\n
.replace(/\n+$/, '\n') // replace trailing newlines with just a single one\r\n
.replace(/\n/gm, '\n '); // indent\r\n
var prefix = options.bulletListMarker + ' ';\r\n
var parent = node.parentNode;\r\n
if (parent.nodeName === 'OL') {\r\n
var start = parent.getAttribute('start');\r\n
var index = Array.prototype.indexOf.call(parent.children, node);\r\n
prefix = (start ? Number(start) + index : index + 1) + '. ';\r\n
}\r\n
return (\r\n
prefix + content + (node.nextSibling && !/\n$/.test(content) ? '\n' : '')\r\n
)\r\n
}\r\n
};\r\n
\r\n
rules.indentedCodeBlock = {\r\n
filter: function (node, options) {\r\n
return (\r\n
options.codeBlockStyle === 'indented' &&\r\n
node.nodeName === 'PRE' &&\r\n
node.firstChild &&\r\n
node.firstChild.nodeName === 'CODE'\r\n
)\r\n
},\r\n
\r\n
replacement: function (content, node, options) {\r\n
return (\r\n
'\n\n ' +\r\n
node.firstChild.textContent.replace(/\n/g, '\n ') +\r\n
'\n\n'\r\n
)\r\n
}\r\n
};\r\n
\r\n
rules.fencedCodeBlock = {\r\n
filter: function (node, options) {\r\n
return (\r\n
options.codeBlockStyle === 'fenced' &&\r\n
node.nodeName === 'PRE' &&\r\n
node.firstChild &&\r\n
node.firstChild.nodeName === 'CODE'\r\n
)\r\n
},\r\n
\r\n
replacement: function (content, node, options) {\r\n
var className = node.firstChild.getAttribute('class') || '';\r\n
var language = (className.match(/language-(\S+)/) || [null, ''])[1];\r\n
var code = node.firstChild.textContent;\r\n
\r\n
var fenceChar = options.fence.charAt(0);\r\n
var fenceSize = 3;\r\n
var fenceInCodeRegex = new RegExp('^' + fenceChar + '{3,}', 'gm');\r\n
\r\n
var match;\r\n
while ((match = fenceInCodeRegex.exec(code))) {\r\n
if (match[0].length >= fenceSize) {\r\n
fenceSize = match[0].length + 1;\r\n
}\r\n
}\r\n
\r\n
var fence = repeat(fenceChar, fenceSize);\r\n
\r\n
return (\r\n
'\n\n' + fence + language + '\n' +\r\n
code.replace(/\n$/, '') +\r\n
'\n' + fence + '\n\n'\r\n
)\r\n
}\r\n
};\r\n
\r\n
rules.horizontalRule = {\r\n
filter: 'hr',\r\n
\r\n
replacement: function (content, node, options) {\r\n
return '\n\n' + options.hr + '\n\n'\r\n
}\r\n
};\r\n
\r\n
rules.inlineLink = {\r\n
filter: function (node, options) {\r\n
return (\r\n
options.linkStyle === 'inlined' &&\r\n
node.nodeName === 'A' &&\r\n
node.getAttribute('href')\r\n
)\r\n
},\r\n
\r\n
replacement: function (content, node) {\r\n
var href = node.getAttribute('href');\r\n
var title = cleanAttribute(node.getAttribute('title'));\r\n
if (title) title = ' "' + title + '"';\r\n
return '[' + content + '](' + href + title + ')'\r\n
}\r\n
};\r\n
\r\n
rules.referenceLink = {\r\n
filter: function (node, options) {\r\n
return (\r\n
options.linkStyle === 'referenced' &&\r\n
node.nodeName === 'A' &&\r\n
node.getAttribute('href')\r\n
)\r\n
},\r\n
\r\n
replacement: function (content, node, options) {\r\n
var href = node.getAttribute('href');\r\n
var title = cleanAttribute(node.getAttribute('title'));\r\n
if (title) title = ' "' + title + '"';\r\n
var replacement;\r\n
var reference;\r\n
\r\n
switch (options.linkReferenceStyle) {\r\n
case 'collapsed':\r\n
replacement = '[' + content + '][]';\r\n
reference = '[' + content + ']: ' + href + title;\r\n
break\r\n
case 'shortcut':\r\n
replacement = '[' + content + ']';\r\n
reference = '[' + content + ']: ' + href + title;\r\n
break\r\n
default:\r\n
var id = this.references.length + 1;\r\n
replacement = '[' + content + '][' + id + ']';\r\n
reference = '[' + id + ']: ' + href + title;\r\n
}\r\n
\r\n
this.references.push(reference);\r\n
return replacement\r\n
},\r\n
\r\n
references: [],\r\n
\r\n
append: function (options) {\r\n
var references = '';\r\n
if (this.references.length) {\r\n
references = '\n\n' + this.references.join('\n') + '\n\n';\r\n
this.references = []; // Reset references\r\n
}\r\n
return references\r\n
}\r\n
};\r\n
\r\n
rules.emphasis = {\r\n
filter: ['em', 'i'],\r\n
\r\n
replacement: function (content, node, options) {\r\n
if (!content.trim()) return ''\r\n
return options.emDelimiter + content + options.emDelimiter\r\n
}\r\n
};\r\n
\r\n
rules.strong = {\r\n
filter: ['strong', 'b'],\r\n
\r\n
replacement: function (content, node, options) {\r\n
if (!content.trim()) return ''\r\n
return options.strongDelimiter + content + options.strongDelimiter\r\n
}\r\n
};\r\n
\r\n
rules.code = {\r\n
filter: function (node) {\r\n
var hasSiblings = node.previousSibling || node.nextSibling;\r\n
var isCodeBlock = node.parentNode.nodeName === 'PRE' && !hasSiblings;\r\n
\r\n
return node.nodeName === 'CODE' && !isCodeBlock\r\n
},\r\n
\r\n
replacement: function (content) {\r\n
if (!content.trim()) return ''\r\n
\r\n
var delimiter = '`';\r\n
var leadingSpace = '';\r\n
var trailingSpace = '';\r\n
var matches = content.match(/`+/gm);\r\n
if (matches) {\r\n
if (/^`/.test(content)) leadingSpace = ' ';\r\n
if (/`$/.test(content)) trailingSpace = ' ';\r\n
while (matches.indexOf(delimiter) !== -1) delimiter = delimiter + '`';\r\n
}\r\n
\r\n
return delimiter + leadingSpace + content + trailingSpace + delimiter\r\n
}\r\n
};\r\n
\r\n
rules.image = {\r\n
filter: 'img',\r\n
\r\n
replacement: function (content, node) {\r\n
var alt = cleanAttribute(node.getAttribute('alt'));\r\n
var src = node.getAttribute('src') || '';\r\n
var title = cleanAttribute(node.getAttribute('title'));\r\n
var titlePart = title ? ' "' + title + '"' : '';\r\n
return src ? '![' + alt + ']' + '(' + src + titlePart + ')' : ''\r\n
}\r\n
};\r\n
\r\n
function cleanAttribute (attribute) {\r\n
return attribute ? attribute.replace(/(\n+\s*)+/g, '\n') : ''\r\n
}\r\n
\r\n
/**\r\n
* Manages a collection of rules used to convert HTML to Markdown\r\n
*/\r\n
\r\n
function Rules (options) {\r\n
this.options = options;\r\n
this._keep = [];\r\n
this._remove = [];\r\n
\r\n
this.blankRule = {\r\n
replacement: options.blankReplacement\r\n
};\r\n
\r\n
this.keepReplacement = options.keepReplacement;\r\n
\r\n
this.defaultRule = {\r\n
replacement: options.defaultReplacement\r\n
};\r\n
\r\n
this.array = [];\r\n
for (var key in options.rules) this.array.push(options.rules[key]);\r\n
}\r\n
\r\n
Rules.prototype = {\r\n
add: function (key, rule) {\r\n
this.array.unshift(rule);\r\n
},\r\n
\r\n
keep: function (filter) {\r\n
this._keep.unshift({\r\n
filter: filter,\r\n
replacement: this.keepReplacement\r\n
});\r\n
},\r\n
\r\n
remove: function (filter) {\r\n
this._remove.unshift({\r\n
filter: filter,\r\n
replacement: function () {\r\n
return ''\r\n
}\r\n
});\r\n
},\r\n
\r\n
forNode: function (node) {\r\n
if (node.isBlank) return this.blankRule\r\n
var rule;\r\n
\r\n
if ((rule = findRule(this.array, node, this.options))) return rule\r\n
if ((rule = findRule(this._keep, node, this.options))) return rule\r\n
if ((rule = findRule(this._remove, node, this.options))) return rule\r\n
\r\n
return this.defaultRule\r\n
},\r\n
\r\n
forEach: function (fn) {\r\n
for (var i = 0; i < this.array.length; i++) fn(this.array[i], i);\r\n
}\r\n
};\r\n
\r\n
function findRule (rules, node, options) {\r\n
for (var i = 0; i < rules.length; i++) {\r\n
var rule = rules[i];\r\n
if (filterValue(rule, node, options)) return rule\r\n
}\r\n
return void 0\r\n
}\r\n
\r\n
function filterValue (rule, node, options) {\r\n
var filter = rule.filter;\r\n
if (typeof filter === 'string') {\r\n
if (filter === node.nodeName.toLowerCase()) return true\r\n
} else if (Array.isArray(filter)) {\r\n
if (filter.indexOf(node.nodeName.toLowerCase()) > -1) return true\r\n
} else if (typeof filter === 'function') {\r\n
if (filter.call(rule, node, options)) return true\r\n
} else {\r\n
throw new TypeError('`filter` needs to be a string, array, or function')\r\n
}\r\n
}\r\n
\r\n
/**\r\n
* collapseWhitespace(options) removes extraneous whitespace from an the given element.\r\n
*\r\n
* @param {Object} options\r\n
*/\r\n
function collapseWhitespace (options) {\r\n
var element = options.element;\r\n
var isBlock = options.isBlock;\r\n
var isVoid = options.isVoid;\r\n
var isPre = options.isPre || function (node) {\r\n
return node.nodeName === 'PRE'\r\n
};\r\n
\r\n
if (!element.firstChild || isPre(element)) return\r\n
\r\n
var prevText = null;\r\n
var prevVoid = false;\r\n
\r\n
var prev = null;\r\n
var node = next(prev, element, isPre);\r\n
\r\n
while (node !== element) {\r\n
if (node.nodeType === 3 || node.nodeType === 4) { // Node.TEXT_NODE or Node.CDATA_SECTION_NODE\r\n
var text = node.data.replace(/[ \r\n\t]+/g, ' ');\r\n
\r\n
if ((!prevText || / $/.test(prevText.data)) &&\r\n
!prevVoid && text[0] === ' ') {\r\n
text = text.substr(1);\r\n
}\r\n
\r\n
// `text` might be empty at this point.\r\n
if (!text) {\r\n
node = remove(node);\r\n
continue\r\n
}\r\n
\r\n
node.data = text;\r\n
\r\n
prevText = node;\r\n
} else if (node.nodeType === 1) { // Node.ELEMENT_NODE\r\n
if (isBlock(node) || node.nodeName === 'BR') {\r\n
if (prevText) {\r\n
prevText.data = prevText.data.replace(/ $/, '');\r\n
}\r\n
\r\n
prevText = null;\r\n
prevVoid = false;\r\n
} else if (isVoid(node)) {\r\n
// Avoid trimming space around non-block, non-BR void elements.\r\n
prevText = null;\r\n
prevVoid = true;\r\n
}\r\n
} else {\r\n
node = remove(node);\r\n
continue\r\n
}\r\n
\r\n
var nextNode = next(prev, node, isPre);\r\n
prev = node;\r\n
node = nextNode;\r\n
}\r\n
\r\n
if (prevText) {\r\n
prevText.data = prevText.data.replace(/ $/, '');\r\n
if (!prevText.data) {\r\n
remove(prevText);\r\n
}\r\n
}\r\n
}\r\n
\r\n
/**\r\n
* remove(node) removes the given node from the DOM and returns the\r\n
* next node in the sequence.\r\n
*\r\n
* @param {Node} node\r\n
* @return {Node} node\r\n
*/\r\n
function remove (node) {\r\n
var next = node.nextSibling || node.parentNode;\r\n
\r\n
node.parentNode.removeChild(node);\r\n
\r\n
return next\r\n
}\r\n
\r\n
/**\r\n
* next(prev, current, isPre) returns the next node in the sequence, given the\r\n
* current and previous nodes.\r\n
*\r\n
* @param {Node} prev\r\n
* @param {Node} current\r\n
* @param {Function} isPre\r\n
* @return {Node}\r\n
*/\r\n
function next (prev, current, isPre) {\r\n
if ((prev && prev.parentNode === current) || isPre(current)) {\r\n
return current.nextSibling || current.parentNode\r\n
}\r\n
\r\n
return current.firstChild || current.nextSibling || current.parentNode\r\n
}\r\n
\r\n
/*\r\n
* Set up window for Node.js\r\n
*/\r\n
\r\n
var root = (typeof window !== 'undefined' ? window : {});\r\n
\r\n
/*\r\n
* Parsing HTML strings\r\n
*/\r\n
\r\n
function canParseHTMLNatively () {\r\n
var Parser = root.DOMParser;\r\n
var canParse = false;\r\n
\r\n
// Adapted from https://gist.github.com/1129031\r\n
// Firefox/Opera/IE throw errors on unsupported types\r\n
try {\r\n
// WebKit returns null on unsupported types\r\n
if (new Parser().parseFromString('', 'text/html')) {\r\n
canParse = true;\r\n
}\r\n
} catch (e) {}\r\n
\r\n
return canParse\r\n
}\r\n
\r\n
function createHTMLParser () {\r\n
var Parser = function () {};\r\n
\r\n
{\r\n
if (shouldUseActiveX()) {\r\n
Parser.prototype.parseFromString = function (string) {\r\n
var doc = new window.ActiveXObject('htmlfile');\r\n
doc.designMode = 'on'; // disable on-page scripts\r\n
doc.open();\r\n
doc.write(string);\r\n
doc.close();\r\n
return doc\r\n
};\r\n
} else {\r\n
Parser.prototype.parseFromString = function (string) {\r\n
var doc = document.implementation.createHTMLDocument('');\r\n
doc.open();\r\n
doc.write(string);\r\n
doc.close();\r\n
return doc\r\n
};\r\n
}\r\n
}\r\n
return Parser\r\n
}\r\n
\r\n
function shouldUseActiveX () {\r\n
var useActiveX = false;\r\n
try {\r\n
document.implementation.createHTMLDocument('').open();\r\n
} catch (e) {\r\n
if (window.ActiveXObject) useActiveX = true;\r\n
}\r\n
return useActiveX\r\n
}\r\n
\r\n
var HTMLParser = canParseHTMLNatively() ? root.DOMParser : createHTMLParser();\r\n
\r\n
function RootNode (input) {\r\n
var root;\r\n
if (typeof input === 'string') {\r\n
var doc = htmlParser().parseFromString(\r\n
// DOM parsers arrange elements in the <head> and <body>.\r\n
// Wrapping in a custom element ensures elements are reliably arranged in\r\n
// a single element.\r\n
'<x-turndown id="turndown-root">' + input + '</x-turndown>',\r\n
'text/html'\r\n
);\r\n
root = doc.getElementById('turndown-root');\r\n
} else {\r\n
root = input.cloneNode(true);\r\n
}\r\n
collapseWhitespace({\r\n
element: root,\r\n
isBlock: isBlock,\r\n
isVoid: isVoid\r\n
});\r\n
\r\n
return root\r\n
}\r\n
\r\n
var _htmlParser;\r\n
function htmlParser () {\r\n
_htmlParser = _htmlParser || new HTMLParser();\r\n
return _htmlParser\r\n
}\r\n
\r\n
function Node (node) {\r\n
node.isBlock = isBlock(node);\r\n
node.isCode = node.nodeName.toLowerCase() === 'code' || node.parentNode.isCode;\r\n
node.isBlank = isBlank(node);\r\n
node.flankingWhitespace = flankingWhitespace(node);\r\n
return node\r\n
}\r\n
\r\n
function isBlank (node) {\r\n
return (\r\n
!isVoid(node) &&\r\n
!isMeaningfulWhenBlank(node) &&\r\n
/^\s*$/i.test(node.textContent) &&\r\n
!hasVoid(node) &&\r\n
!hasMeaningfulWhenBlank(node)\r\n
)\r\n
}\r\n
\r\n
function flankingWhitespace (node) {\r\n
var leading = '';\r\n
var trailing = '';\r\n
\r\n
if (!node.isBlock) {\r\n
var hasLeading = /^\s/.test(node.textContent);\r\n
var hasTrailing = /\s$/.test(node.textContent);\r\n
var blankWithSpaces = node.isBlank && hasLeading && hasTrailing;\r\n
\r\n
if (hasLeading && !isFlankedByWhitespace('left', node)) {\r\n
leading = ' ';\r\n
}\r\n
\r\n
if (!blankWithSpaces && hasTrailing && !isFlankedByWhitespace('right', node)) {\r\n
trailing = ' ';\r\n
}\r\n
}\r\n
\r\n
return { leading: leading, trailing: trailing }\r\n
}\r\n
\r\n
function isFlankedByWhitespace (side, node) {\r\n
var sibling;\r\n
var regExp;\r\n
var isFlanked;\r\n
\r\n
if (side === 'left') {\r\n
sibling = node.previousSibling;\r\n
regExp = / $/;\r\n
} else {\r\n
sibling = node.nextSibling;\r\n
regExp = /^ /;\r\n
}\r\n
\r\n
if (sibling) {\r\n
if (sibling.nodeType === 3) {\r\n
isFlanked = regExp.test(sibling.nodeValue);\r\n
} else if (sibling.nodeType === 1 && !isBlock(sibling)) {\r\n
isFlanked = regExp.test(sibling.textContent);\r\n
}\r\n
}\r\n
return isFlanked\r\n
}\r\n
\r\n
var reduce = Array.prototype.reduce;\r\n
var leadingNewLinesRegExp = /^\n*/;\r\n
var trailingNewLinesRegExp = /\n*$/;\r\n
var escapes = [\r\n
[/\\/g, '\\\\'],\r\n
[/\*/g, '\\*'],\r\n
[/^-/g, '\\-'],\r\n
[/^\+ /g, '\\+ '],\r\n
[/^(=+)/g, '\\$1'],\r\n
[/^(#{1,6}) /g, '\\$1 '],\r\n
[/`/g, '\\`'],\r\n
[/^~~~/g, '\\~~~'],\r\n
[/\[/g, '\\['],\r\n
[/\]/g, '\\]'],\r\n
[/^>/g, '\\>'],\r\n
[/_/g, '\\_'],\r\n
[/^(\d+)\. /g, '$1\\. ']\r\n
];\r\n
\r\n
function TurndownService (options) {\r\n
if (!(this instanceof TurndownService)) return new TurndownService(options)\r\n
\r\n
var defaults = {\r\n
rules: rules,\r\n
headingStyle: 'setext',\r\n
hr: '* * *',\r\n
bulletListMarker: '*',\r\n
codeBlockStyle: 'indented',\r\n
fence: '```',\r\n
emDelimiter: '_',\r\n
strongDelimiter: '**',\r\n
linkStyle: 'inlined',\r\n
linkReferenceStyle: 'full',\r\n
br: ' ',\r\n
blankReplacement: function (content, node) {\r\n
return node.isBlock ? '\n\n' : ''\r\n
},\r\n
keepReplacement: function (content, node) {\r\n
return node.isBlock ? '\n\n' + node.outerHTML + '\n\n' : node.outerHTML\r\n
},\r\n
defaultReplacement: function (content, node) {\r\n
return node.isBlock ? '\n\n' + content + '\n\n' : content\r\n
}\r\n
};\r\n
this.options = extend({}, defaults, options);\r\n
this.rules = new Rules(this.options);\r\n
}\r\n
\r\n
TurndownService.prototype = {\r\n
/**\r\n
* The entry point for converting a string or DOM node to Markdown\r\n
* @public\r\n
* @param {String|HTMLElement} input The string or DOM node to convert\r\n
* @returns A Markdown representation of the input\r\n
* @type String\r\n
*/\r\n
\r\n
turndown: function (input) {\r\n
if (!canConvert(input)) {\r\n
throw new TypeError(\r\n
input + ' is not a string, or an element/document/fragment node.'\r\n
)\r\n
}\r\n
\r\n
if (input === '') return ''\r\n
\r\n
var output = process.call(this, new RootNode(input));\r\n
return postProcess.call(this, output)\r\n
},\r\n
\r\n
/**\r\n
* Add one or more plugins\r\n
* @public\r\n
* @param {Function|Array} plugin The plugin or array of plugins to add\r\n
* @returns The Turndown instance for chaining\r\n
* @type Object\r\n
*/\r\n
\r\n
use: function (plugin) {\r\n
if (Array.isArray(plugin)) {\r\n
for (var i = 0; i < plugin.length; i++) this.use(plugin[i]);\r\n
} else if (typeof plugin === 'function') {\r\n
plugin(this);\r\n
} else {\r\n
throw new TypeError('plugin must be a Function or an Array of Functions')\r\n
}\r\n
return this\r\n
},\r\n
\r\n
/**\r\n
* Adds a rule\r\n
* @public\r\n
* @param {String} key The unique key of the rule\r\n
* @param {Object} rule The rule\r\n
* @returns The Turndown instance for chaining\r\n
* @type Object\r\n
*/\r\n
\r\n
addRule: function (key, rule) {\r\n
this.rules.add(key, rule);\r\n
return this\r\n
},\r\n
\r\n
/**\r\n
* Keep a node (as HTML) that matches the filter\r\n
* @public\r\n
* @param {String|Array|Function} filter The unique key of the rule\r\n
* @returns The Turndown instance for chaining\r\n
* @type Object\r\n
*/\r\n
\r\n
keep: function (filter) {\r\n
this.rules.keep(filter);\r\n
return this\r\n
},\r\n
\r\n
/**\r\n
* Remove a node that matches the filter\r\n
* @public\r\n
* @param {String|Array|Function} filter The unique key of the rule\r\n
* @returns The Turndown instance for chaining\r\n
* @type Object\r\n
*/\r\n
\r\n
remove: function (filter) {\r\n
this.rules.remove(filter);\r\n
return this\r\n
},\r\n
\r\n
/**\r\n
* Escapes Markdown syntax\r\n
* @public\r\n
* @param {String} string The string to escape\r\n
* @returns A string with Markdown syntax escaped\r\n
* @type String\r\n
*/\r\n
\r\n
escape: function (string) {\r\n
return escapes.reduce(function (accumulator, escape) {\r\n
return accumulator.replace(escape[0], escape[1])\r\n
}, string)\r\n
}\r\n
};\r\n
\r\n
/**\r\n
* Reduces a DOM node down to its Markdown string equivalent\r\n
* @private\r\n
* @param {HTMLElement} parentNode The node to convert\r\n
* @returns A Markdown representation of the node\r\n
* @type String\r\n
*/\r\n
\r\n
function process (parentNode) {\r\n
var self = this;\r\n
return reduce.call(parentNode.childNodes, function (output, node) {\r\n
node = new Node(node);\r\n
\r\n
var replacement = '';\r\n
if (node.nodeType === 3) {\r\n
replacement = node.isCode ? node.nodeValue : self.escape(node.nodeValue);\r\n
} else if (node.nodeType === 1) {\r\n
replacement = replacementForNode.call(self, node);\r\n
}\r\n
\r\n
return join(output, replacement)\r\n
}, '')\r\n
}\r\n
\r\n
/**\r\n
* Appends strings as each rule requires and trims the output\r\n
* @private\r\n
* @param {String} output The conversion output\r\n
* @returns A trimmed version of the ouput\r\n
* @type String\r\n
*/\r\n
\r\n
function postProcess (output) {\r\n
var self = this;\r\n
this.rules.forEach(function (rule) {\r\n
if (typeof rule.append === 'function') {\r\n
output = join(output, rule.append(self.options));\r\n
}\r\n
});\r\n
\r\n
return output.replace(/^[\t\r\n]+/, '').replace(/[\t\r\n\s]+$/, '')\r\n
}\r\n
\r\n
/**\r\n
* Converts an element node to its Markdown equivalent\r\n
* @private\r\n
* @param {HTMLElement} node The node to convert\r\n
* @returns A Markdown representation of the node\r\n
* @type String\r\n
*/\r\n
\r\n
function replacementForNode (node) {\r\n
var rule = this.rules.forNode(node);\r\n
var content = process.call(this, node);\r\n
var whitespace = node.flankingWhitespace;\r\n
if (whitespace.leading || whitespace.trailing) content = content.trim();\r\n
return (\r\n
whitespace.leading +\r\n
rule.replacement(content, node, this.options) +\r\n
whitespace.trailing\r\n
)\r\n
}\r\n
\r\n
/**\r\n
* Determines the new lines between the current output and the replacement\r\n
* @private\r\n
* @param {String} output The current conversion output\r\n
* @param {String} replacement The string to append to the output\r\n
* @returns The whitespace to separate the current output and the replacement\r\n
* @type String\r\n
*/\r\n
\r\n
function separatingNewlines (output, replacement) {\r\n
var newlines = [\r\n
output.match(trailingNewLinesRegExp)[0],\r\n
replacement.match(leadingNewLinesRegExp)[0]\r\n
].sort();\r\n
var maxNewlines = newlines[newlines.length - 1];\r\n
return maxNewlines.length < 2 ? maxNewlines : '\n\n'\r\n
}\r\n
\r\n
function join (string1, string2) {\r\n
var separator = separatingNewlines(string1, string2);\r\n
\r\n
// Remove trailing/leading newlines and replace with separator\r\n
string1 = string1.replace(trailingNewLinesRegExp, '');\r\n
string2 = string2.replace(leadingNewLinesRegExp, '');\r\n
\r\n
return string1 + separator + string2\r\n
}\r\n
\r\n
/**\r\n
* Determines whether an input can be converted\r\n
* @private\r\n
* @param {String|HTMLElement} input Describe this parameter\r\n
* @returns Describe what it returns\r\n
* @type String|Object|Array|Boolean|Number\r\n
*/\r\n
\r\n
function canConvert (input) {\r\n
return (\r\n
input != null && (\r\n
typeof input === 'string' ||\r\n
(input.nodeType && (\r\n
input.nodeType === 1 || input.nodeType === 9 || input.nodeType === 11\r\n
))\r\n
)\r\n
)\r\n
}\r\n
\r\n
return TurndownService;\r\n
\r\n
}());\r\n
\r\n
\r\n
var options = {"headingStyle":"atx","hr":"***","bulletListMarker":"-","codeBlockStyle":"fenced","fence":"```","emDelimiter":"*","strongDelimiter":"**","linkStyle":"inlined","linkReferenceStyle":"full","preformattedCode":true};\r\n
\r\n
var turndownService = new window.TurndownService(options);\r\n
\r\n
var highlightRegExp = /highlight-(?:text|source)-([a-z0-9]+)/;\r\n
\r\n
function highlightedCodeBlock (turndownService) {\r\n
turndownService.addRule('highlightedCodeBlock', {\r\n
filter: function (node) {\r\n
var firstChild = node.firstChild;\r\n
return (\r\n
node.nodeName === 'DIV' &&\r\n
highlightRegExp.test(node.className) &&\r\n
firstChild &&\r\n
firstChild.nodeName === 'PRE'\r\n
)\r\n
},\r\n
replacement: function (content, node, options) {\r\n
var className = node.className || '';\r\n
var language = (className.match(highlightRegExp) || [null, ''])[1];\r\n
\r\n
return (\r\n
'\n\n' + options.fence + language + '\n' +\r\n
node.firstChild.textContent +\r\n
'\n' + options.fence + '\n\n'\r\n
)\r\n
}\r\n
});\r\n
}\r\n
\r\n
function strikethrough (turndownService) {\r\n
turndownService.addRule('strikethrough', {\r\n
filter: ['del', 's', 'strike'],\r\n
replacement: function (content) {\r\n
return '~' + content + '~'\r\n
}\r\n
});\r\n
}\r\n
\r\n
var indexOf = Array.prototype.indexOf;\r\n
var every = Array.prototype.every;\r\n
var rules = {};\r\n
\r\n
rules.tableCell = {\r\n
filter: ['th', 'td'],\r\n
replacement: function (content, node) {\r\n
return cell(content, node)\r\n
}\r\n
};\r\n
\r\n
rules.tableRow = {\r\n
filter: 'tr',\r\n
replacement: function (content, node) {\r\n
var borderCells = '';\r\n
var alignMap = { left: ':--', right: '--:', center: ':-:' };\r\n
\r\n
if (isHeadingRow(node)) {\r\n
for (var i = 0; i < node.childNodes.length; i++) {\r\n
var border = '---';\r\n
var align = (\r\n
node.childNodes[i].getAttribute('align') || ''\r\n
).toLowerCase();\r\n
\r\n
if (align) border = alignMap[align] || border;\r\n
\r\n
borderCells += cell(border, node.childNodes[i]);\r\n
}\r\n
}\r\n
return '\n' + content + (borderCells ? '\n' + borderCells : '')\r\n
}\r\n
};\r\n
\r\n
rules.table = {\r\n
// Only convert tables with a heading row.\r\n
// Tables with no heading row are kept using `keep` (see below).\r\n
filter: function (node) {\r\n
return node.nodeName === 'TABLE' && isHeadingRow(node.rows[0])\r\n
},\r\n
\r\n
replacement: function (content) {\r\n
// Ensure there are no blank lines\r\n
content = content.replace('\n\n', '\n');\r\n
return '\n\n' + content + '\n\n'\r\n
}\r\n
};\r\n
\r\n
rules.tableSection = {\r\n
filter: ['thead', 'tbody', 'tfoot'],\r\n
replacement: function (content) {\r\n
return content\r\n
}\r\n
};\r\n
\r\n
// A tr is a heading row if:\r\n
// - the parent is a THEAD\r\n
// - or if its the first child of the TABLE or the first TBODY (possibly\r\n
// following a blank THEAD)\r\n
// - and every cell is a TH\r\n
function isHeadingRow (tr) {\r\n
var parentNode = tr.parentNode;\r\n
return (\r\n
parentNode.nodeName === 'THEAD' ||\r\n
(\r\n
parentNode.firstChild === tr &&\r\n
(parentNode.nodeName === 'TABLE' || isFirstTbody(parentNode)) &&\r\n
every.call(tr.childNodes, function (n) { return n.nodeName === 'TH' })\r\n
)\r\n
)\r\n
}\r\n
\r\n
function isFirstTbody (element) {\r\n
var previousSibling = element.previousSibling;\r\n
return (\r\n
element.nodeName === 'TBODY' && (\r\n
!previousSibling ||\r\n
(\r\n
previousSibling.nodeName === 'THEAD' &&\r\n
/^\s*$/i.test(previousSibling.textContent)\r\n
)\r\n
)\r\n
)\r\n
}\r\n
\r\n
function cell (content, node) {\r\n
var index = indexOf.call(node.parentNode.childNodes, node);\r\n
var prefix = ' ';\r\n
if (index === 0) prefix = '| ';\r\n
return prefix + content + ' |'\r\n
}\r\n
\r\n
function tables (turndownService) {\r\n
turndownService.keep(function (node) {\r\n
return node.nodeName === 'TABLE' && !isHeadingRow(node.rows[0])\r\n
});\r\n
for (var key in rules) turndownService.addRule(key, rules[key]);\r\n
}\r\n
\r\n
function taskListItems (turndownService) {\r\n
turndownService.addRule('taskListItems', {\r\n
filter: function (node) {\r\n
return node.type === 'checkbox' && node.parentNode.nodeName === 'LI'\r\n
},\r\n
replacement: function (content, node) {\r\n
return (node.checked ? '[x]' : '[ ]') + ' '\r\n
}\r\n
});\r\n
}\r\n
\r\n
function gfm (turndownService) {\r\n
turndownService.use([\r\n
highlightedCodeBlock,\r\n
strikethrough,\r\n
tables,\r\n
taskListItems\r\n
]);\r\n
}\r\n
\r\n
\r\n
gfm(turndownService);\r\n
highlightedCodeBlock(turndownService);\r\n
strikethrough(turndownService);\r\n
tables(turndownService);\r\n
taskListItems(turndownService);\r\n
\r\n
var selectedHtml = "";\r\n
var documentFragment = window.getSelection().getRangeAt(0).cloneContents();\r\n
\r\n
for(var i=0;i<documentFragment.childNodes.length;i++){\r\n
\tvar childNode = documentFragment.childNodes[i];\r\n
\tif(childNode.nodeType==3){\r\n
\t\tselectedHtml+=childNode.nodeValue;\r\n
\t}else{\r\n
\t\tvar nodeHtml = childNode.outerHTML;\r\n
\t\tselectedHtml+=nodeHtml;\r\n
\t}\r\n
}\r\n
\r\n
turndownService.turndown(selectedHtml);
在 Quicker.Utilities._3rd.Chrome.ChromeControlClient.SendToBrowser(ChromeCommandMessage msg, Boolean waitResponse, String browser)
在 Quicker.Utilities._3rd.Chrome.ChromeControl.SendMessageToBrowser(ChromeCommandMessage msg, String browser, Boolean waitResponse, Int32 timeoutMs)
在 qeqguf1Le2PSLhpUPda.hQT5Ul1mXv4mLXll9hy.<>c__DisplayClass84_0.hG9b542eqk6()
在 Quicker.Domain.Actions.X.XActionHelper.ExecuteCommonAction(ActionExecuteContext context, ActionStep step, XAction action, Func`1 actionFunc, Action successAction, Action failAction, StepInParamDef stopIfErrorParam, StepOutParamDef isSuccessOutputParam)
StartHTML:0000000187\r\n
EndHTML:0000019105\r\n
StartFragment:0000000223\r\n
EndFragment:0000019069\r\n
SourceURL:http://cnzhx.net/blog/auto-number-fig-or-table-in-word/#insert_caption\r\n
<html>\r\n
<body>\r\n
<!--StartFragment--><h2 id="insert_caption" style="border: 0px; font-family: "Source Sans Pro", sans-serif; font-size: 1.2em; font-style: normal; font-weight: 700; margin: 0px 0px 0.8125em; outline: 0px; padding: 0.3em; vertical-align: baseline; clear: both; color: rgb(245, 245, 245); text-indent: 10px; background: rgb(29, 153, 243); text-shadow: rgba(0, 0, 0, 0.3) 0px -1px 0px; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">1. 添加自动编号<span class="anchorlink" style="border: 0px; font-family: inherit; font-size: smaller; font-style: inherit; font-weight: inherit; margin: 0px 0.25em; outline: 0px; padding: 0px 0.5em; vertical-align: baseline; background-color: transparent; color: transparent; text-decoration: none;"><a href="http://cnzhx.net/blog/auto-number-fig-or-table-in-word/#insert_caption" style="border: 0px; font-family: inherit; font-size: 14px; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: transparent; text-decoration: none; overflow-wrap: break-word; overflow: hidden; background-color: transparent;">¶</a></span></h2><p style="border: 0px; font-family: "Source Sans Pro", sans-serif; font-size: 14px; font-style: normal; font-weight: 400; margin: 0px 0px 1em; outline: 0px; padding: 0px; vertical-align: baseline; line-height: 1.625em; color: rgb(55, 55, 55); font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Word 有内置的题注格式,如果不想用,还可以新建新的格式。在文档中新建之后,以后就可以直接用了。</p><h3 id="i-1" style="border: 0px; font-family: "Source Sans Pro", sans-serif; font-size: 1.2em; font-style: normal; font-weight: 700; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; clear: both; color: rgb(204, 0, 0); letter-spacing: 0.1em; line-height: 2.6em; text-transform: uppercase; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; text-align: start; text-indent: 0px; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">首先,插入题注。<span class="anchorlink" style="border: 0px; font-family: inherit; font-size: smaller; font-style: inherit; font-weight: inherit; margin: 0px 0.25em; outline: 0px; padding: 0px 0.5em; vertical-align: baseline; background-color: transparent; color: transparent; text-decoration: none;"><a href="http://cnzhx.net/blog/auto-number-fig-or-table-in-word/#i-1" style="border: 0px; font-family: inherit; font-size: 14px; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: transparent; text-decoration: none; overflow-wrap: break-word; overflow: hidden; background-color: transparent;">¶</a></span></h3><p style="border: 0px; font-family: "Source Sans Pro", sans-serif; font-size: 14px; font-style: normal; font-weight: 400; margin: 0px 0px 1em; outline: 0px; padding: 0px; vertical-align: baseline; line-height: 1.625em; color: rgb(55, 55, 55); font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">插入需要的图片,在图片上单击鼠标右键,选择“<strong style="border: 0px; font-family: inherit; font-size: 14px; font-style: inherit; font-weight: 700; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">插入题注</strong>”(Insert Caption,如下图所示),</p><div id="attachment_7368" class="wp-caption aligncenter" style="border: 0px; font-family: "Source Sans Pro", sans-serif; font-size: 14px; font-style: normal; font-weight: 400; margin: 0px auto; outline: 0px; padding: 0px; vertical-align: baseline; clear: both; display: block; max-width: calc(100% - 18px); color: rgb(55, 55, 55); font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; width: 517px;"><a href="http://cnzhx.net/wp-content/uploads/2013/05/word-fig-insert-cation.png" style="border: 0px; font-family: inherit; font-size: 14px; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(29, 153, 243); text-decoration: none; overflow-wrap: break-word; overflow: hidden;"><img aria-describedby="caption-attachment-7368" class="size-full wp-image-7368 " title="Word 中为图片右键单击选择“插入题注”(Insert Caption)" src="http://cnzhx.net/wp-content/uploads/2013/05/word-fig-insert-cation.png" alt="Word 中为图片右键单击选择“插入题注”(Insert Caption)" width="507" height="455" style="border: 0px; max-width: calc(100% - 14px); height: auto; width: auto; display: block; padding: 6px;"></a><p id="caption-attachment-7368" class="wp-caption-text" style="border: 0px; font-family: Tinos, serif; font-size: 0.875rem; font-style: inherit; font-weight: inherit; margin: 0px 0px 0.6em; outline: 0px; padding: 10px 0px 5px 40px; vertical-align: baseline; line-height: 1.625em; color: rgb(102, 102, 102); position: relative; overflow-wrap: break-word; overflow: hidden;">Word 中为图片右键单击选择“插入题注”(Insert Caption)</p></div><h3 id="i-2" style="border: 0px; font-family: "Source Sans Pro", sans-serif; font-size: 1.2em; font-style: normal; font-weight: 700; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; clear: both; color: rgb(204, 0, 0); letter-spacing: 0.1em; line-height: 2.6em; text-transform: uppercase; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; text-align: start; text-indent: 0px; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">第二,调整配置。<span class="anchorlink" style="border: 0px; font-family: inherit; font-size: smaller; font-style: inherit; font-weight: inherit; margin: 0px 0.25em; outline: 0px; padding: 0px 0.5em; vertical-align: baseline; background-color: transparent; color: transparent; text-decoration: none;"><a href="http://cnzhx.net/blog/auto-number-fig-or-table-in-word/#i-2" style="border: 0px; font-family: inherit; font-size: 14px; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: transparent; text-decoration: none; overflow-wrap: break-word; overflow: hidden; background-color: transparent;">¶</a></span></h3><p style="border: 0px; font-family: "Source Sans Pro", sans-serif; font-size: 14px; font-style: normal; font-weight: 400; margin: 0px 0px 1em; outline: 0px; padding: 0px; vertical-align: baseline; line-height: 1.625em; color: rgb(55, 55, 55); font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">在弹出的<strong style="border: 0px; font-family: inherit; font-size: 14px; font-style: inherit; font-weight: 700; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">题注设置对话框</strong>(如下图所示)中输入/设置题注的标题(输入标题时最好在前面自动生成的题注标签和编号后面输入一个空格),选项中的标签、(题注)位置,还可以勾选下面的排除标签选项。</p><div id="attachment_7369" class="wp-caption aligncenter" style="border: 0px; font-family: "Source Sans Pro", sans-serif; font-size: 14px; font-style: normal; font-weight: 400; margin: 0px auto; outline: 0px; padding: 0px; vertical-align: baseline; clear: both; display: block; max-width: calc(100% - 18px); color: rgb(55, 55, 55); font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; width: 522px;"><a href="http://cnzhx.net/wp-content/uploads/2013/05/word-fig-caption-dialog.png" style="border: 0px; font-family: inherit; font-size: 14px; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(29, 153, 243); text-decoration: none; overflow-wrap: break-word; overflow: hidden;"><img aria-describedby="caption-attachment-7369" loading="lazy" class="size-full wp-image-7369" src="http://cnzhx.net/wp-content/uploads/2013/05/word-fig-caption-dialog.png" alt="Word 图片题注对话框" width="512" height="368" style="border: 0px; max-width: calc(100% - 14px); height: auto; width: auto; display: block; padding: 6px;"></a><p id="caption-attachment-7369" class="wp-caption-text" style="border: 0px; font-family: Tinos, serif; font-size: 0.875rem; font-style: inherit; font-weight: inherit; margin: 0px 0px 0.6em; outline: 0px; padding: 10px 0px 5px 40px; vertical-align: baseline; line-height: 1.625em; color: rgb(102, 102, 102); position: relative; overflow-wrap: break-word; overflow: hidden;">Word 图片题注对话框</p></div><p style="border: 0px; font-family: "Source Sans Pro", sans-serif; font-size: 14px; font-style: normal; font-weight: 400; margin: 0px 0px 1em; outline: 0px; padding: 0px; vertical-align: baseline; line-height: 1.625em; color: rgb(55, 55, 55); font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">如果已经新建过标签了,可以在选择标签那一栏右边的小箭头那里找到。</p><h3 id="i-3" style="border: 0px; font-family: "Source Sans Pro", sans-serif; font-size: 1.2em; font-style: normal; font-weight: 700; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; clear: both; color: rgb(204, 0, 0); letter-spacing: 0.1em; line-height: 2.6em; text-transform: uppercase; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; text-align: start; text-indent: 0px; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">第三,新建标签。<span class="anchorlink" style="border: 0px; font-family: inherit; font-size: smaller; font-style: inherit; font-weight: inherit; margin: 0px 0.25em; outline: 0px; padding: 0px 0.5em; vertical-align: baseline; background-color: transparent; color: transparent; text-decoration: none;"><a href="http://cnzhx.net/blog/auto-number-fig-or-table-in-word/#i-3" style="border: 0px; font-family: inherit; font-size: 14px; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: transparent; text-decoration: none; overflow-wrap: break-word; overflow: hidden; background-color: transparent;">¶</a></span></h3><p style="border: 0px; font-family: "Source Sans Pro", sans-serif; font-size: 14px; font-style: normal; font-weight: 400; margin: 0px 0px 1em; outline: 0px; padding: 0px; vertical-align: baseline; line-height: 1.625em; color: rgb(55, 55, 55); font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">如果默认的题注形式不符合要求,还可以自己创建一个“<strong style="border: 0px; font-family: inherit; font-size: 14px; font-style: inherit; font-weight: 700; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">新标签</strong>”(New Label),也可以只更改“编号”。比如上面默认的标签是 Figure,我想改成“<strong style="border: 0px; font-family: inherit; font-size: 14px; font-style: inherit; font-weight: 700; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">图</strong>”。于是单击“新建标签”,在弹出的对话框中输入“图”(不要引号),此时题注对话框的第一行的自动生成部分就符合要求了。</p><h3 id="i-4" style="border: 0px; font-family: "Source Sans Pro", sans-serif; font-size: 1.2em; font-style: normal; font-weight: 700; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; clear: both; color: rgb(204, 0, 0); letter-spacing: 0.1em; line-height: 2.6em; text-transform: uppercase; font-variant-ligatures: normal; font-variant-caps: normal; orphans: 2; text-align: start; text-indent: 0px; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">第四,修改编号格式。<span class="anchorlink" style="border: 0px; font-family: inherit; font-size: smaller; font-style: inherit; font-weight: inherit; margin: 0px 0.25em; outline: 0px; padding: 0px 0.5em; vertical-align: baseline; background-color: transparent; color: transparent; text-decoration: none;"><a href="http://cnzhx.net/blog/auto-number-fig-or-table-in-word/#i-4" style="border: 0px; font-family: inherit; font-size: 14px; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: transparent; text-decoration: none; overflow-wrap: break-word; overflow: hidden; background-color: transparent;">¶</a></span></h3><p style="border: 0px; font-family: "Source Sans Pro", sans-serif; font-size: 14px; font-style: normal; font-weight: 400; margin: 0px 0px 1em; outline: 0px; padding: 0px; vertical-align: baseline; line-height: 1.625em; color: rgb(55, 55, 55); font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">一般毕业论文中的图和表,其题注的编号需要带上章节号,例如,图1-1 xxx。此时,我们单击“编号”(Numbering),打开“题注编号”(Caption Numbering)对话框,如下图所示。</p><div id="attachment_7370" class="wp-caption aligncenter" style="border: 0px; font-family: "Source Sans Pro", sans-serif; font-size: 14px; font-style: normal; font-weight: 400; margin: 0px auto; outline: 0px; padding: 0px; vertical-align: baseline; clear: both; display: block; max-width: calc(100% - 18px); color: rgb(55, 55, 55); font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; width: 574px;"><a href="http://cnzhx.net/wp-content/uploads/2013/05/word-fig-cation-numbering-dialog.png" style="border: 0px; font-family: inherit; font-size: 14px; font-style: inherit; font-weight: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(29, 153, 243); text-decoration: underline; overflow-wrap: break-word; overflow: hidden;"><img aria-describedby="caption-attachment-7370" loading="lazy" class="size-full wp-image-7370" src="http://cnzhx.net/wp-content/uploads/2013/05/word-fig-cation-numbering-dialog.png" alt="Word 图片题注编号设置对话框" width="564" height="374" style="border: 0px; max-width: calc(100% - 14px); height: auto; width: auto; display: block; padding: 6px;"></a><p id="caption-attachment-7370" class="wp-caption-text" style="border: 0px; font-family: Tinos, serif; font-size: 0.875rem; font-style: inherit; font-weight: inherit; margin: 0px 0px 0.6em; outline: 0px; padding: 10px 0px 5px 40px; vertical-align: baseline; line-height: 1.625em; color: rgb(102, 102, 102); position: relative; overflow-wrap: break-word; overflow: hidden;">Word 图片题注编号设置对话框</p></div><p style="border: 0px; font-family: "Source Sans Pro", sans-serif; font-size: 14px; font-style: normal; font-weight: 400; margin: 0px 0px 1em; outline: 0px; padding: 0px; vertical-align: baseline; line-height: 1.625em; color: rgb(55, 55, 55); font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">选中“包含章节号”(Include chapter</p><!--EndFragment-->\r\n
</body>\r\n
</html>
\r\n
Word 有内置的题注格式,如果不想用,还可以新建新的格式。在文档中新建之后,以后就可以直接用了。\r\n
\r\n
### 首先,插入题注。[¶](http://cnzhx.net/blog/auto-number-fig-or-table-in-word/#i-1)\r\n
\r\n
插入需要的图片,在图片上单击鼠标右键,选择“**插入题注**”(Insert Caption,如下图所示),\r\n
\r\n
http://cnzhx.net/wp-content/uploads/2013/05/word-fig-insert-cation.png\r\n
Word 中为图片右键单击选择“插入题注”(Insert Caption)\r\n
\r\n
\r\n
### 第二,调整配置。[¶](http://cnzhx.net/blog/auto-number-fig-or-table-in-word/#i-2)\r\n
\r\n
在弹出的**题注设置对话框**(如下图所示)中输入/设置题注的标题(输入标题时最好在前面自动生成的题注标签和编号后面输入一个空格),选项中的标签、(题注)位置,还可以勾选下面的排除标签选项。\r\n
\r\n
http://cnzhx.net/wp-content/uploads/2013/05/word-fig-caption-dialog.png\r\n
Word 图片题注对话框\r\n
\r\n
\r\n
如果已经新建过标签了,可以在选择标签那一栏右边的小箭头那里找到。\r\n
\r\n
### 第三,新建标签。[¶](http://cnzhx.net/blog/auto-number-fig-or-table-in-word/#i-3)\r\n
\r\n
如果默认的题注形式不符合要求,还可以自己创建一个“**新标签**”(New Label),也可以只更改“编号”。比如上面默认的标签是 Figure,我想改成“**图**”。于是单击“新建标签”,在弹出的对话框中输入“图”(不要引号),此时题注对话框的第一行的自动生成部分就符合要求了。\r\n
\r\n
### 第四,修改编号格式。[¶](http://cnzhx.net/blog/auto-number-fig-or-table-in-word/#i-4)\r\n
\r\n
一般毕业论文中的图和表,其题注的编号需要带上章节号,例如,图1-1 xxx。此时,我们单击“编号”(Numbering),打开“题注编号”(Caption Numbering)对话框,如下图所示。\r\n
\r\n
http://cnzhx.net/wp-content/uploads/2013/05/word-fig-cation-numbering-dialog.png\r\n
Word 图片题注编号设置对话框\r\n
\r\n
\r\n
选中“包含章节号”(Include chapter
\r\n
Word 有内置的题注格式,如果不想用,还可以新建新的格式。在文档中新建之后,以后就可以直接用了。\r\n
\r\n
### 首先,插入题注。[¶](http://cnzhx.net/blog/auto-number-fig-or-table-in-word/#i-1)\r\n
\r\n
插入需要的图片,在图片上单击鼠标右键,选择“**插入题注**”(Insert Caption,如下图所示),\r\n
\r\n
http://cnzhx.net/wp-content/uploads/2013/05/word-fig-insert-cation.png\r\n
Word 中为图片右键单击选择“插入题注”(Insert Caption)\r\n
\r\n
\r\n
### 第二,调整配置。[¶](http://cnzhx.net/blog/auto-number-fig-or-table-in-word/#i-2)\r\n
\r\n
在弹出的**题注设置对话框**(如下图所示)中输入/设置题注的标题(输入标题时最好在前面自动生成的题注标签和编号后面输入一个空格),选项中的标签、(题注)位置,还可以勾选下面的排除标签选项。\r\n
\r\n
http://cnzhx.net/wp-content/uploads/2013/05/word-fig-caption-dialog.png\r\n
Word 图片题注对话框\r\n
\r\n
\r\n
如果已经新建过标签了,可以在选择标签那一栏右边的小箭头那里找到。\r\n
\r\n
### 第三,新建标签。[¶](http://cnzhx.net/blog/auto-number-fig-or-table-in-word/#i-3)\r\n
\r\n
如果默认的题注形式不符合要求,还可以自己创建一个“**新标签**”(New Label),也可以只更改“编号”。比如上面默认的标签是 Figure,我想改成“**图**”。于是单击“新建标签”,在弹出的对话框中输入“图”(不要引号),此时题注对话框的第一行的自动生成部分就符合要求了。\r\n
\r\n
### 第四,修改编号格式。[¶](http://cnzhx.net/blog/auto-number-fig-or-table-in-word/#i-4)\r\n
\r\n
一般毕业论文中的图和表,其题注的编号需要带上章节号,例如,图1-1 xxx。此时,我们单击“编号”(Numbering),打开“题注编号”(Caption Numbering)对话框,如下图所示。\r\n
\r\n
http://cnzhx.net/wp-content/uploads/2013/05/word-fig-cation-numbering-dialog.png\r\n
Word 图片题注编号设置对话框\r\n
\r\n
\r\n
选中“包含章节号”(Include chapter
这个是e
我给您发了复制文档和截图,希望能对您有用,谢谢
不好意思,因为你这几条回复回的其实是你自己的帖子,所以我一直没收到通知,直到现在才看到😂
看了一下调试日志,是没连接上扩展程序,所以动作调用了 Quicker 的公共API来转换的。
但这个 API 好像不支持嵌套在 a 标签里的 img,所以没能正确处理。
试了一下,Turndown 的转换结果是正常的。
API 的问题我已经向 @CL 反馈了,建议现在先安装 Quicker 扩展,用 Turndown 顶着。