소스 검색

Workflow manual fix. Copy to clipboard is wip.

Mikael Säker 7 년 전
부모
커밋
6680327314
2개의 변경된 파일24개의 추가작업 그리고 5개의 파일을 삭제
  1. 2 2
      docs/en/manuals/workflow.md
  2. 22 3
      gulpfile.js

+ 2 - 2
docs/en/manuals/workflow.md

@@ -36,7 +36,6 @@ This brings up a window where you can inspect your changes and write a _useful_
 
 ![Commit changes](images/workflow/workflow_commit.png)
 
-
 To inspect the changes that have been done to a file, simply double click the file in the commit-list to open the Compare window:
 
 ![Compare changes](images/workflow/workflow_compare_script.png)
@@ -158,7 +157,8 @@ input
 
 You can configure Git with more fine grained control on how it should deal with line endings by creating a *.gitattributes* file in your repository:
 
-```txt
+```
+<hello></hello>
 # Set default behaviour, in case users don't have core.autocrlf set.
 * text=auto
 

+ 22 - 3
gulpfile.js

@@ -116,6 +116,26 @@ md.renderer.rules.image = function (tokens, idx, options, env, self) {
     return self.renderToken(tokens, idx, options);
 };
 
+var HTML_ESCAPE_TEST_RE = /[&<>"]/;
+var HTML_ESCAPE_REPLACE_RE = /[&<>"]/g;
+var HTML_REPLACEMENTS = {
+  '&': '&amp;',
+  '<': '&lt;',
+  '>': '&gt;',
+  '"': '&quot;'
+};
+
+function replaceUnsafeChar(ch) {
+  return HTML_REPLACEMENTS[ch];
+}
+
+function escapeHtml(str) {
+  if (HTML_ESCAPE_TEST_RE.test(str)) {
+    return str.replace(HTML_ESCAPE_REPLACE_RE, replaceUnsafeChar);
+  }
+  return str;
+}
+
 // Fence code blocks
 md.renderer.rules.fence = function (tokens, idx, options, env, self) {
   var token = tokens[idx],
@@ -128,9 +148,9 @@ md.renderer.rules.fence = function (tokens, idx, options, env, self) {
   }
 
   if (options.highlight) {
-    highlighted = options.highlight(token.content, langName) || encodeURI(token.content);
+    highlighted = options.highlight(token.content, langName) || escapeHtml(token.content);
   } else {
-    highlighted = encodeURI(token.content);
+    highlighted = escapeHtml(token.content);
   }
 
   if (highlighted.indexOf('<pre') === 0) {
@@ -163,7 +183,6 @@ md.renderer.rules.fence = function (tokens, idx, options, env, self) {
           + '</code>' + copy + '</pre>\n';
   }
 
-
   return  '<pre>' + '<code id="' + id +'"' + self.renderAttrs(token) + '>'
         + highlighted
         + '</code>' + copy + '</pre>\n';