Przeglądaj źródła

Merge pull request #9 from weseek/imprv/linker-processable-square-brackets

improve Linker PreProcessor
Yuki Takei 9 lat temu
rodzic
commit
96a34f3b54
1 zmienionych plików z 4 dodań i 1 usunięć
  1. 4 1
      resource/js/util/PreProcessor/Linker.js

+ 4 - 1
resource/js/util/PreProcessor/Linker.js

@@ -3,8 +3,11 @@ export default class Linker {
   process(markdown) {
 
     return markdown
-      //.replace(/\s(https?:\/\/[\S]+)/g, ' <a href="$1">$1</a>') // リンク
+      // process angle branckets like '</Level1/Level2>'
       .replace(/\s<((\/[^>]+?){2,})>/g, ' <a href="$1">$1</a>') // ページ間リンク: <> でかこまれてて / から始まり、 / が2個以上
+      // process square branckets like '[/Level1]'
+      // see: https://regex101.com/r/QSt1yu/1
+      .replace(/\[(\/[^\]]+?)\]/g, ' <a href="$1">$1</a>')
       ;
   }
 }