From 62ba3733cdce9c4004788acfa2a79147ddf6ab0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Estev=C3=A3o=20Soares=20dos=20Santos?= Date: Tue, 14 Jul 2015 17:10:52 +0100 Subject: [PATCH] feat(smoothLivePreview): fix weird effects due to parsing incomplete input --- dist/showdown.js | Bin 63982 -> 64130 bytes dist/showdown.js.map | Bin 207317 -> 206576 bytes dist/showdown.min.js | Bin 22540 -> 22775 bytes dist/showdown.min.js.map | Bin 25168 -> 25336 bytes src/options.js | 5 +++++ src/subParsers/headers.js | 21 ++++++--------------- 6 files changed, 11 insertions(+), 15 deletions(-) diff --git a/dist/showdown.js b/dist/showdown.js index 12fb6bfaed0fd56d2cc97616fa999d1e24a9b4c1..c5ac6da5585177f649dd05a505b78132c876c16b 100644 GIT binary patch delta 375 zcmaF&nYrmJ^M*BSlQ*!k2^Qz(=a*#oWR|4{6s4ABrj}1mV9~Y*u~YL(iWSOJGmBCb zQq$5>lYzXVnt%62=K}lwQUa=mA3p5q%74+jY^t3gj6=F(awPNyY ztBrJOVH|D!^jrlibQRjj(mGrq8{u|(f-N;7(NbM3mQJ3(L}s!=j3h6LZzdO(%564S ZoX?0NY_xgz5=N%U$`#_9S1xxA0s!aRf*t?> delta 245 zcmZqr%KYv#^M*BSo4wgD&1SToEVnp$vc?K=F+FX~XoZ-PSgn{mTWuIid-A$e#my_1 z#6rlb}rl%!Uapel_~)&dy{Ha5SYBr`uRF-IXeC%+hE zHqc-NjXbsd5{2aa(!7$?6itxkm^^I|rJtUwqmWjbmkiRRp{X$0x>#+q?F!c*0N@Ts A00000 diff --git a/dist/showdown.js.map b/dist/showdown.js.map index 5a96e8b51f19ce20254d83362b7c376317021d30..2554dfaa7baba0972fcbbe29da682387316dd634 100644 GIT binary patch delta 4595 zcmb_edvH|M8J~05O|mzS-DG!@Y#^H(LWMxc3o*!ZHz6TF0?WhB01>i;OR{9MS$A(@ zkb*(9&NyQYeub|cQDg0BeIU_4Olw;WPMrY(*`VT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9f3+{{X)20uRjRG^O-ejE zT2|Vn=GDGN#kH_V!q+x)2TCXT0$lVcRW@*v-xRN`j9;AOdU~cN6<|(}I#Bi=UX2G{ z;idRe4{i5at9p7=O8>csy9KHjm9FR%1-xy?h)_d7RcqE#kTOcCVWKL@ytY9bfWvA>11Fdhk~5sB%ni z;l^&ckMGf;?I=&%d72lcs>1AWtoD%_hZ_AsPYCCp=2dw6I-=sP)4cNPlMY9n;SO`c zp*|G$1Y1LGAzZSKkk*~y)8dx&q``w{_;`a)5y^JR;|+PF4fw?wJ~nPq{0W~Ie|q#2 TUZzou(A38Zx(7eunp^${Q#8}D diff --git a/dist/showdown.min.js b/dist/showdown.min.js index 1c7a2d164c132018c98fda9884694a9198f1de25..3ff6774583695c3fdebfa2c8ad0d64d6598b5c74 100644 GIT binary patch delta 241 zcmeC#!1#S5Nj^|KIX|}`C$%IM$Sf$`Je6gcvAIr$ZIT{_>Gt|@ z8hYBA(F!pov05>Cw$(;DwJ?shetNFeWPb};vrHni>SAh@w3M05s3tNw+>Li~xy2&J P%*ojn(VHh&*2n<>_Wo4= delta 39 xcmV+?0NDTcu>p**0kEe8vmynQGm{Y^6_f5b9FuZ6t&>1G9FuW5TeEvQd>%g@4?h3^ diff --git a/dist/showdown.min.js.map b/dist/showdown.min.js.map index 3f5a104948dbe2219b47ba9fd6c65186af884397..f17eed50669bda9e7d381a5ac1415bf83b1df302 100644 GIT binary patch delta 4684 zcmai2Uu;`f8JDY#I;CmonsgaW(k<=Qs=3T|;>5N_+nsxSeRF($b8}-muKQnU_8aOBx7l;8l8c5AHV3lF! zhUUOYZ9g%b_nh$Qn$64thtC+x%ZDe=*Je0l4a@8M ze;E1j$eDT+t;rz(KD~hpZg97cAL6By%GAjC}3X$0rVM3g(pfjC^7A zr=F7hXmrXG-v7(!w}wv5BO3fJT4(`Ed@*mz$7d(@e>fHKJneA*@!40uIMj}54RGsf zaQ~H=A3uA{7t{Q>%*XftCUdM z!8Q|G9{tR<1)UXmA+|+_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%jCa?4}@Y4GH7x8V8RH~lSw9k_O{+NM^1TB*a- zQTXg$|9(>?l%aTpW+Qe2J`H1qA|VA$zzIX8oo1TM?y%opO{KjJVR+f8>3DI*3y7MD zDtfI{DjuhCBv!&4qE9^hP%{y;w^e~K&^t{El#$&{Q$LN!WkMX9%Am%n&3RiStkwrUJlrPNVhSTFMS z$NBSq_E^qr!$0Oj7uDiXP}y+Eozx0^=iSJ))=o?44qbAEnK_)^xDA8zXS+K5hR@#} zyu-o7%L>Y-PHD@=J7T`WWI{(Hzssm+;lQGRZb09{^)WWCq~k3?b#d!(g%V`Uk`b=@ z%A8YK@DPQ{u(oiaw?5P1#U2mRf9+{6V&%h@1oKN#w65Ehuz8YV!@?!YGx0^e?CQN5kV+Q$^yn^_WC RAj~u#1?foGiOki<{{sa8$lL$` diff --git a/src/options.js b/src/options.js index 0f11c72..9364938 100644 --- a/src/options.js +++ b/src/options.js @@ -65,6 +65,11 @@ function getDefaultOpts(simple) { default: false, describe: 'Turn on/off GFM tasklist support', type: 'boolean' + }, + smoothLivePreview: { + default: false, + describe: 'Prevents weird effects in live previews due to incomplete input', + type: 'boolean' } }; if (simple === false) { diff --git a/src/subParsers/headers.js b/src/subParsers/headers.js index 811a493..ea9d862 100644 --- a/src/subParsers/headers.js +++ b/src/subParsers/headers.js @@ -2,7 +2,7 @@ showdown.subParser('headers', function (text, options, globals) { 'use strict'; var prefixHeader = options.prefixHeaderId, - headerLevelStart = (isNaN(parseInt(options.headerLevelStart))) ? 1 : parseInt(options.headerLevelStart); + headerLevelStart = (isNaN(parseInt(options.headerLevelStart))) ? 1 : parseInt(options.headerLevelStart), // Set text-style headers: // Header 1 @@ -11,7 +11,10 @@ showdown.subParser('headers', function (text, options, globals) { // Header 2 // -------- // - text = text.replace(/^(.+)[ \t]*\n=+[ \t]*\n+/gm, function (wholeMatch, m1) { + setextRegexH1 = (options.smoothLivePreview) ? /^(.+)[ \t]*\n={2,}[ \t]*\n+/gm : /^(.+)[ \t]*\n=+[ \t]*\n+/gm, + setextRegexH2 = (options.smoothLivePreview) ? /^(.+)[ \t]*\n-{2,}[ \t]*\n+/gm : /^(.+)[ \t]*\n-+[ \t]*\n+/gm; + + text = text.replace(setextRegexH1, function (wholeMatch, m1) { var spanGamut = showdown.subParser('spanGamut')(m1, options, globals), hID = (options.noHeaderId) ? '' : ' id="' + headerId(m1) + '"', @@ -20,7 +23,7 @@ showdown.subParser('headers', function (text, options, globals) { return showdown.subParser('hashBlock')(hashBlock, options, globals); }); - text = text.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm, function (matchFound, m1) { + text = text.replace(setextRegexH2, function (matchFound, m1) { var spanGamut = showdown.subParser('spanGamut')(m1, options, globals), hID = (options.noHeaderId) ? '' : ' id="' + headerId(m1) + '"', hLevel = headerLevelStart + 1, @@ -35,18 +38,6 @@ showdown.subParser('headers', function (text, options, globals) { // ... // ###### Header 6 // - - /* - text = text.replace(/ - ^(\#{1,6}) // $1 = string of #'s - [ \t]* - (.+?) // $2 = Header text - [ \t]* - \#* // optional closing #'s (not counted) - \n+ - /gm, function() {...}); - */ - text = text.replace(/^(#{1,6})[ \t]*(.+?)[ \t]*#*\n+/gm, function (wholeMatch, m1, m2) { var span = showdown.subParser('spanGamut')(m2, options, globals), hID = (options.noHeaderId) ? '' : ' id="' + headerId(m2) + '"',