From 0c0cd7db999537321ddab12a9c2bd02e74db920f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Estev=C3=A3o=20Soares=20dos=20Santos?= Date: Sat, 11 Jul 2015 15:45:58 +0100 Subject: [PATCH] feat(literalMidWordUnderscores): add support for GFM literal midword underscores Github Flavored Markdown does not parse underscores in the middle of a word as emphasis/bold. This commit adds this feature to showdown through an option called "literalMidWordUnderscores". Related to #164 --- dist/showdown.js | Bin 55779 -> 56166 bytes dist/showdown.js.map | Bin 179714 -> 178543 bytes dist/showdown.min.js | Bin 18207 -> 18448 bytes dist/showdown.min.js.map | Bin 20357 -> 20522 bytes src/converter.js | 6 +----- src/showdown.js | 13 +++++++------ src/subParsers/italicsAndBold.js | 18 ++++++++++++++---- ...disallow_underscore_emphasis_mid_word.html | 11 +++++++++++ ...2.disallow_underscore_emphasis_mid_word.md | 11 +++++++++++ test/node/showdown.js | 13 +++++++------ test/node/testsuite.features.js | 2 ++ 11 files changed, 53 insertions(+), 21 deletions(-) create mode 100644 test/features/#164.2.disallow_underscore_emphasis_mid_word.html create mode 100644 test/features/#164.2.disallow_underscore_emphasis_mid_word.md diff --git a/dist/showdown.js b/dist/showdown.js index d7c0430980707fb3cfc38c4aad5c5802daaacbba..561e2b1c94bd2fd6db25aef578829c5690084986 100644 GIT binary patch delta 502 zcmaF7nfci^<_WhM6(-(NpRCHrKbenFa| zGe56b52tobg=#JZAkfz@MVJW{Q3%e=OHNfNPgO`PN>xY(np2vanU}7Rs1Q@EkercN zl$Z>3lnzKiUTSKJLP@?tVoHiaW(ipTFiZ$coHSBF;f;Baw<6^b#q1<9k z{d64#brnOK;*z5LymUJiBO84vQ(e<~^1+jm_7L5unn65--qc*MJ|G3u19f&{G0;_+ z#o5ImGYs`(v|_YSi~tFM?S|WIh;Fk9P#2mWhz^i_K-EzDfELy&q~;W-f&+1~;R^Z5 lM^1`OPFZ0$`Ory;$vao*F#}ahcDx}v**}(jGxN#^1^|Xrpg;fs delta 135 zcmaF1jrs9r<_Wha-c_4i$;dldh*5H~E~DDyP(~#nUv2YAMhRtRE(L{&d*l_;5_5`E zb$}cQC@4xz%dGH7O-xBG@=UQ(P?%iEC^}hyQJM#=5UOtTLzPcWlOJSDPTssyYI13z b=;S9WZ6_<;l$dO_N_TQolJw@*RSyjS?cXn^ diff --git a/dist/showdown.js.map b/dist/showdown.js.map index cb968bfcd1d4ab3bfb9e59d39f66f80faf35b319..c14a07544df10b8828f299d05be0a44c809e4080 100644 GIT binary patch delta 8279 zcmb_g3viTGmahBLolgH9x;shd(H)Zf2?=@7q|?Lz8XoyOgrM^101=TOX_C&1&}q6m z5dsMTOJpbqLm%O~K4x%ScN`xxaka{Ic7RxpGwT#C@i|V37}nLDsdbe&;sY4jbMO5- zFOademV&1L```1p-#Oa0@LstWwqUFBSa06rb8N)pHI6 zeXJahJa{Mpez(@jk6q@0!{s)9>>jwXHjOX3Jdm?aEQVmoy0pa%${Rfb%UGtZ5%{u4 zQFXC+wrigAH*66S-%X+B*N7~ySJm}Q%PwHW0j|@t$48xDh zP`5q>Mm8G2GDi;&Hd~;6Wda;spUIpc0XV*XNglJQxx?#|J&PnAd-TFN#{xLsZh>95 z|CqyGUIRn7i|`I@(94Vr_<23(Y!USTT&DdsB$?HgVZI0k_#R1tp$$%sOQ4zq2G1Q# zfz+ohx-sZKv=W&%tisal^OuQazYhNI+%bolklL%jT9^V2hxD}JBr(%t%Sj##-;M}u zlBv>#DL$O0htqrY(FLMB%i-npR8U@$VdT#;9Zts`C-e01`bIO1{9X?q*fXN_1>Dne zErJW{v&6wYaIP+ei}t@~gps@BV9uQ~SkvN32%fHg3xU;>Fu$Y_beC17IT#4YY`^rJO%|M*;lc+ zfHx-#ynW`QdC1lR;+r9(5DoEnGW^M$0QdTmSzdzq$MN85GioGH3LS8?&JLCP=Obex zkZya_lLRXsh=;C&77Vk6Zg!&9fd};TY#+f0Vn&pEXihi58p%h~1@R;Z54M#k3|wqo zyuD6p&aDC+E)#7xLNHrLB5=8}hq>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If7Sdk-GfSq&-s@~$z%3odKgmtFsg;Zfy2{Mas$P+H!()YMHwY5>6w^w6 z5m9XOud+;1S@@x%dH+>5$-gR7CE;ryvWbJmqk^TNp?D%fBBWxjv1ETN?AKTbIwIwLD>rmt4j%johkHK8cuzHM%@l`zA}F2k~JPp1!GMz`2_&KG<(z zGwz?jM_G!>-PNwra=AsmkC;tvS-jk{dorKRJiG7XdGz-+J|15>z(?)=i5qe84jzNC zjE9rniHzTlC5+pYWh{7#>qA=dlT!w=^d-i}s!QJmK26{}!5`|mT&Tx~I8PB_@soi} zELB$Sb*-Yjh`Wsw(Qx{+Z!FhGQnyQ&1y8$ksa32ksH`m){g$K(6alQgjgKOYty-$z zr)e*JKB?snJo6mI=How6BBf{)3HKHH-%bgAR%>sw`t}hGpQ_6KL4hHpKp;{#Ppv=EqS1_ukJC24|r zV!S`KRGEQBGt7}lEDGi_x`TOqq$;frRkG||Q(2$pDl5ZXdP)+N<`2_HNzEwY3V(OJ z5=?=bq~}Hcavr9jp&mbw=zuOg4<>I&!T90cT-0+>6|oY(8`nxai$3qA4MQvXZHbE} zO6)ZrV?%g|$XIG`{hzS7q3kw4MA_XO!ex@~2;no-eEK|ui>Z-FJQiaNJX~p}IKQ1s z_-Q+_{&E9PP$jn-c+zkpKW5+-RbIb|8#RMYYm7V*#~bkJ?z>R-T7{uBAeHe=DDi P`TO{!!{hJg^QQhU-mL|& diff --git a/dist/showdown.min.js b/dist/showdown.min.js index ab88b4c810650adc6da253b6bd195d484c0f2b26..b9e9494d4b491e246c86c48030ec511b97554b45 100644 GIT binary patch delta 302 zcmbQ=$2egEQwRoA(MQt4v-k zEjalB8@qRs9!}Nv8i}@vdPS)PIf==s8u}VB#hUT)8uqp^!I~P;ak1L=P;RlNe!7m5 zis9r83)Om{8dN199!!NzYObA%k&Ql(Qqt5xF+D~rMhitFNC0H6O>s$4eqOqrilL1@ ll!>Vqu2Tx+ET~41Wk5|}%QUStCYxE*GXrhiywxI$4*WIswxDpoy99f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+}GpD$i+-ZXToz##EdJv40Y;H{^0pnd`EuHjP(aiqFAB z!U@wH+SDUlnh2mJ(*H4{IpJCpOg0CylvYx_gImbUe4)k{Y;J;c0e;9bJ1QtI_!=L# zs_HaEGjgB`LsKwda;pF}A!iyZM6SytX7f`~$VXK_7q zm_Fd_<*-7H1HE*@d}v^kc(5Ms3H77Yc}$XjktzEQ5@rP~a<7FU5}^V^8T{w)R1DyDX9x`T z0w%9UO?@f7?&33BQqN?l%9+ZXM;V#UOkMMGe6s~S{Fu7jMnB$o-rml{y!MH7%EMwG zHGJf4j7arQ8w7{B)TSDool3{Eh0=w_gz|T3|Je( z(|dFM!%+?k%OW)vsv4X6*9Tq`PF4N!+~CneeJraha%2)c39-VgOt#FtEH=h%tf47e z31v|$%5@{iLi0HbYmm~>OBRTkyM``u+Y>bG0dH9@*_^)z9Z8ZV3c^9Q&f*s(Zvuh= z)3|z+J>9HEUz=|kaJ-vs8E`yl{TOULw$S>~M&KLsEd(Bq4XFQ|Ki#N{x%yf~aocDw zhU}||hk5$~;$hVerg@kRwlY_GNAdqd0R&@|LYCr8K@3BlC4k-rq%tK z3+m_g;0PBAvg{5?b0%4Y9(#a>dVWH9UBwsXE_=g2&I?PzOnL)=r1aAdsXInk{n>)u zh}~085P#1&!~J{gDg2nmomf6e;>dN~z}3_v$L@@hvoi($O>Q}+e&7Vg;`|QZ2{H__ Wp?Q*iiDJ!sb%M4;HZnK-`u_o*C1?r& diff --git a/src/converter.js b/src/converter.js index f06ce10..32e8db4 100644 --- a/src/converter.js +++ b/src/converter.js @@ -22,11 +22,7 @@ showdown.Converter = function (converterOptions) { * @private * @type {{}} */ - options = { - omitExtraWLInCodeBlocks: false, - prefixHeaderId: false, - noHeaderId: false - }, + options = {}, /** * Language extensions used by this converter diff --git a/src/showdown.js b/src/showdown.js index 16ed157..a0ee56f 100644 --- a/src/showdown.js +++ b/src/showdown.js @@ -7,12 +7,13 @@ var showdown = {}, parsers = {}, extensions = {}, defaultOptions = { - omitExtraWLInCodeBlocks: false, - prefixHeaderId: false, - noHeaderId: false, - headerLevelStart: 1, - parseImgDimensions: false, - simplifiedAutoLink: false + omitExtraWLInCodeBlocks: false, + prefixHeaderId: false, + noHeaderId: false, + headerLevelStart: 1, + parseImgDimensions: false, + simplifiedAutoLink: false, + literalMidWordUnderscores: false }, globalOptions = JSON.parse(JSON.stringify(defaultOptions)); //clone default options out of laziness =P diff --git a/src/subParsers/italicsAndBold.js b/src/subParsers/italicsAndBold.js index 3601b9e..34223fc 100644 --- a/src/subParsers/italicsAndBold.js +++ b/src/subParsers/italicsAndBold.js @@ -1,9 +1,19 @@ -showdown.subParser('italicsAndBold', function (text) { +showdown.subParser('italicsAndBold', function (text, options) { 'use strict'; - // must go first: - text = text.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g, '$2'); - text = text.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g, '$2'); + if (options.literalMidWordUnderscores) { + //underscores + // Since we are consuming a \s character, we need to add it + text = text.replace(/(\s)__(?=\S)([^]+?)__(?=\s)/g, '$1$2'); + text = text.replace(/(\s)_(?=\S)([^]+?)_(?=\s)/g, '$1$2'); + //asterisks + text = text.replace(/\*\*(?=\S)([^]+?)\*\*/g, '$1'); + text = text.replace(/\*(?=\S)([^]+?)\*/g, '$1'); + } else { + // must go first: + text = text.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g, '$2'); + text = text.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g, '$2'); + } return text; }); diff --git a/test/features/#164.2.disallow_underscore_emphasis_mid_word.html b/test/features/#164.2.disallow_underscore_emphasis_mid_word.html new file mode 100644 index 0000000..0a3196c --- /dev/null +++ b/test/features/#164.2.disallow_underscore_emphasis_mid_word.html @@ -0,0 +1,11 @@ +

this is a sentence_with_mid underscores

+ +

this is a sentence with just_one underscore

+ +

this should be parsed as emphasis

+ +

this is double__underscore__mid word

+ +

this has just__one double underscore

+ +

this should be parsed as bold

diff --git a/test/features/#164.2.disallow_underscore_emphasis_mid_word.md b/test/features/#164.2.disallow_underscore_emphasis_mid_word.md new file mode 100644 index 0000000..85c6fc5 --- /dev/null +++ b/test/features/#164.2.disallow_underscore_emphasis_mid_word.md @@ -0,0 +1,11 @@ +this is a sentence_with_mid underscores + +this is a sentence with just_one underscore + +this _should be parsed_ as emphasis + +this is double__underscore__mid word + +this has just__one double underscore + +this __should be parsed__ as bold diff --git a/test/node/showdown.js b/test/node/showdown.js index 8d5c89c..80834ff 100644 --- a/test/node/showdown.js +++ b/test/node/showdown.js @@ -18,12 +18,13 @@ describe('showdown.options', function () { describe('getDefaultOptions()', function () { it('should get default options', function () { var opts = { - omitExtraWLInCodeBlocks: false, - prefixHeaderId: false, - noHeaderId: false, - headerLevelStart: 1, - parseImgDimensions: false, - simplifiedAutoLink: false + omitExtraWLInCodeBlocks: false, + prefixHeaderId: false, + noHeaderId: false, + headerLevelStart: 1, + parseImgDimensions: false, + simplifiedAutoLink: false, + literalMidWordUnderscores: false }; expect(showdown.getDefaultOptions()).to.be.eql(opts); }); diff --git a/test/node/testsuite.features.js b/test/node/testsuite.features.js index 894fa8b..77e0e24 100644 --- a/test/node/testsuite.features.js +++ b/test/node/testsuite.features.js @@ -16,6 +16,8 @@ describe('makeHtml() features testsuite', function () { converter = new showdown.Converter({headerLevelStart: 3}); } else if (testsuite[i].name === '#164.1.simple_autolink') { converter = new showdown.Converter({simplifiedAutoLink: true}); + } else if (testsuite[i].name === '#164.2.disallow_underscore_emphasis_mid_word') { + converter = new showdown.Converter({literalMidWordUnderscores: true}); } else { converter = new showdown.Converter(); }