Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

* impl remove hatena keyword option

  • Loading branch information...
commit e66d1ca82723d2f0ded9895fec65aaf075d1986f 1 parent b3dcb9c
@Constellation Constellation authored
Showing with 12 additions and 2 deletions.
  1. +12 −2 src/lib/utils.js
View
14 src/lib/utils.js
@@ -527,7 +527,7 @@ function resolveRelativePath(base){
// (c) id:nanto_vi
// http://nanto.asablo.jp/blog/2010/02/05/4858761
-function convertToHTMLString(source, safe) {
+function convertToHTMLString(source, safe, hatena) {
if (!source || (source.getRangeAt && source.isCollapsed)) return '';
var range = source.getRangeAt ? source.getRangeAt(0) : null;
var node = range ? range.cloneContents() : source.cloneNode(true);
@@ -550,6 +550,16 @@ function convertToHTMLString(source, safe) {
$X('descendant-or-self::*[contains(" img embed ", concat(" ", local-name(.), " "))]', root).forEach(convertToHTMLString.resetter.src);
$X("descendant-or-self::object", root).forEach(convertToHTMLString.resetter.data);
+ if(hatena){
+ var keyword = node.ownerDocument.createElement('span');
+ keyword.setAttribute('class', 'keyword');
+ $X('descendant-or-self::a[(@class="keyword") or (@class="okeyword")]', root).forEach(function(key){
+ var r = keyword.cloneNode(false);
+ $A(key.childNodes).forEach(function(child){ r.appendChild(child.cloneNode(true)) });
+ key.parentNode.replaceChild(r, key);
+ });
+ }
+
node = appendChildNodes($DF(), root.childNodes);
}
return new XMLSerializer().serializeToString(node);
@@ -589,7 +599,7 @@ function getSelectionContents(sel){
function createFlavoredString(src){
return {
raw : src.textContent || src.toString(),
- html : convertToHTMLString(src, true)
+ html : convertToHTMLString(src, true, !!TBRL.config['post']['remove_hatena_keyword'])
};
}
Please sign in to comment.
Something went wrong with that request. Please try again.