Commit Graph

205 Commits

Author SHA1 Message Date
Aidan Woods
4a215f33d4
Trim in renderer 2019-04-07 16:38:19 +01:00
Aidan Woods
3ccd64a9a1
Expand public API of Components
Ref: https://github.com/erusev/parsedown/issues/694
2019-04-07 16:38:19 +01:00
Aidan Woods
3c0b528d54
Constructor shouldn't be part of public API 2019-04-07 16:38:18 +01:00
Aidan Woods
f83ee87902
Make this pattern a bit more reusable 2019-04-07 16:38:18 +01:00
Aidan Woods
a396fccace
No contexts implies everything being appended is a blank line
(of which where is at least one).
2019-04-07 16:38:18 +01:00
Aidan Woods
4fb6ac31a5
Improve tests 2019-04-07 16:38:18 +01:00
Aidan Woods
c0792947a6
Remove unused methods 2019-04-07 16:38:17 +01:00
Aidan Woods
65450f47cd
Simplify 2019-04-07 16:38:17 +01:00
Aidan Woods
fc23ca5ef5
Remove more redundant checks 2019-04-07 16:38:17 +01:00
Aidan Woods
015e476f3e
Remove unused import 2019-04-07 16:38:17 +01:00
Aidan Woods
289b641a42
Remove inaccurate comment 2019-04-07 16:38:17 +01:00
Aidan Woods
147a87a4f3
These are self-explainitory 2019-04-07 16:38:16 +01:00
Aidan Woods
b90efc69ec
Ensure marker is properly contained in the Inline 2019-04-07 16:38:16 +01:00
Aidan Woods
30613b2430
Ensure $startPosition is positive 2019-04-07 16:38:16 +01:00
Aidan Woods
5ecfc42728
Early exit if found 2019-04-07 16:38:16 +01:00
Aidan Woods
3bb24c20a6
Assert marker is correct for hard and soft breaks 2019-04-07 16:38:16 +01:00
Aidan Woods
369aea5d8d
Collect State from continuable state updating block on advance 2019-04-07 16:38:15 +01:00
Aidan Woods
2b79d599fb
Require State to build and advance blocks 2019-04-07 16:38:15 +01:00
Aidan Woods
df703dcb0e
Missed one 2019-04-07 16:38:15 +01:00
Aidan Woods
36fac49ed8
Remove redundant checks
These don't appear to have a measurable positive impact on performance.
2019-04-07 16:38:15 +01:00
Aidan Woods
41fb6b0d43
Move url sanitisation out of Element class 2019-04-07 16:38:15 +01:00
Aidan Woods
a681cf631c
Acquisition capable blocks as an interface 2019-04-07 16:38:15 +01:00
Aidan Woods
c2973100e0
Fix whitespace trimming for soft and hard breaks 2019-04-07 16:38:14 +01:00
Aidan Woods
2efae741bb
Simplify expression 2019-04-07 16:38:14 +01:00
Aidan Woods
660c2e43a3
Paragraph would end itself and new one must start for header row to
exist
2019-04-07 16:38:13 +01:00
Aidan Woods
d9792bb12c
Ensure markers are checked when beginning blocks 2019-04-07 16:38:13 +01:00
Aidan Woods
08c40afc16
Test against HTML block endings 2019-04-07 16:38:13 +01:00
Aidan Woods
c310625b93
Length not necessary 2019-04-07 16:38:13 +01:00
Aidan Woods
54f2c4eb4c
Fix recovered spaces calculation 2019-04-07 16:38:12 +01:00
Aidan Woods
117912c373
Substr over indexing string 2019-04-07 16:38:12 +01:00
Aidan Woods
63a97a926b
Remove leftover hackyness 2019-04-07 16:38:12 +01:00
Aidan Woods
cb211a88a8
PHP < 7 compat 2019-04-07 16:38:12 +01:00
Aidan Woods
c49d40027f
Add StateBearer which can carry state 2019-04-07 16:38:11 +01:00
Aidan Woods
4dee1e9a55
Add convenience instance-based initialisers 2019-04-07 16:38:11 +01:00
Aidan Woods
dbc0efeec0
Require integer-keyed lists so that array_merge result is predictable 2019-04-07 16:38:11 +01:00
Aidan Woods
a2bca78f7e
Fix whitespace errors 2019-04-07 16:38:11 +01:00
Aidan Woods
f47ba7aa34
Track whitespace left on blank lines to match CommonMark
Test changes copy pasted to match CommonMark reference parser
2019-04-07 16:38:10 +01:00
Aidan Woods
49dd8b113d
Make sure closing sequence is removed correctly 2019-04-07 16:38:10 +01:00
Aidan Woods
30763a0f38
HTML tags should have a name 2019-04-07 16:38:10 +01:00
Aidan Woods
3dd1326ded
Trim paragraph contents 2019-04-07 16:38:10 +01:00
Aidan Woods
0f55cd5b26
Permit empty links 2019-04-07 16:38:10 +01:00
Aidan Woods
82d20d8ffe
Markup like CommonMark 2019-04-07 16:38:09 +01:00
Aidan Woods
7fd6e0bb31
Backslash escape like CommonMark 2019-04-07 16:38:09 +01:00
Aidan Woods
eab734b457
Match CommonMark's rendering a bit better 2019-04-07 16:38:08 +01:00
Aidan Woods
2e0ad27c5e
CommonMark escapes double-quotes 2019-04-07 16:38:08 +01:00
Aidan Woods
d6c97ee111
Make escaping slightly less aggressive 2019-04-07 16:38:08 +01:00
Aidan Woods
62615f4fc5
Allow empty code spans 2019-04-07 16:38:08 +01:00
Aidan Woods
4563ee592d
Don't assume marker type is correct 2019-04-07 16:38:07 +01:00
Aidan Woods
aab56cf8cc
Fix strange formatting 2019-04-07 16:38:07 +01:00
Aidan Woods
48c0c34470
Caching for initial configurable values removes need to seed state 2019-04-07 16:38:07 +01:00
Aidan Woods
bc3c1544c5
Don't special case invisible
If something has no html, it doesn't need to have a newline
2019-04-07 16:38:06 +01:00
Aidan Woods
d6f526d80f
Return state after block parse instead of mutating the instance copy 2019-04-07 16:38:06 +01:00
Aidan Woods
b728f254b7
Ensure Url parsing is removed all the way down (not just edge) 2019-04-07 16:38:06 +01:00
Aidan Woods
d733c262c2
Cleanup logical operators 2019-04-07 16:38:06 +01:00
Aidan Woods
11da347aa1
We don't need to pass a Parsedown instance down
Since Parsedown is instancible from State, we only
need to carry that down.
2019-04-07 16:38:05 +01:00
Aidan Woods
b89bd0e3c2
Add breaks configurable 2019-04-07 16:38:05 +01:00
Aidan Woods
fce09a702a
Put reused code in a trait so boolean configurables are easy to make 2019-04-07 16:38:05 +01:00
Aidan Woods
8fe93f30ac
Add easy way to remove Components from InlineTyes and BlockTypes 2019-04-07 16:38:05 +01:00
Aidan Woods
9f9ef78662
This should be slightly faster
Merge would honour changes, and removals
are equivalent to changing to default value.
2019-04-07 16:38:05 +01:00
Aidan Woods
57632f38fb
More meaningful method name 2019-04-07 16:38:05 +01:00
Aidan Woods
5e7fb61879
More keyword fixes for pre-PHP7 2019-04-07 16:38:05 +01:00
Aidan Woods
2618509cc6
Now the class is a bit shorter we can remove these makeshift dividers 2019-04-07 16:38:04 +01:00
Aidan Woods
fce4633ff9
Inlines and Blocks as Configurables 2019-04-07 16:38:04 +01:00
Aidan Woods
eb90905d27
Default value is intrinsic to a configurable, we can just always
retrieve that.
2019-04-07 16:38:04 +01:00
Aidan Woods
5a50930cb0
Allow inlines to backtrack into characters that were suspected as
inlines but ruled out
This is required for backslash escaped Hard breaks to work:
Parsedown first checks to see if these are escape sequences,
however when they are ruled out they should not be assumed to be
plaintext since a later inline (Hardbreak) may backtrack into these
unconsumed characters.
2019-04-07 16:38:04 +01:00
Aidan Woods
1fd2e14b72
Add hard and soft breaks 2019-04-07 16:38:04 +01:00
Aidan Woods
714ae50211
Text variable isn't very useful inside the loop 2019-04-07 16:38:04 +01:00
Aidan Woods
14b3761687
Produce Blocks before converting to StateRenderables
(As we do with Inlines)
2019-04-07 16:38:04 +01:00
Aidan Woods
00821bd072
Don't remove right #'s too early (before dealing with whitesapce) 2019-04-07 16:38:03 +01:00
Aidan Woods
b8cdc6e9a5
Remove closing # sequence from header 2019-04-07 16:38:03 +01:00
Aidan Woods
67231cbae1
Tabs are allowed after header delimiter 2019-04-07 16:38:03 +01:00
Aidan Woods
81a2050608
Headers can't start with more than three spaces 2019-04-07 16:38:03 +01:00
Aidan Woods
3d41f270c2
Better name for testing safe mode and strict mode state
Add a nice named constructor
2019-04-07 16:38:03 +01:00
Aidan Woods
bb424e606f
Improve indent handling by lists 2019-04-07 16:38:03 +01:00
Aidan Woods
51c3d9d445
Make it clearer this is one backslash character 2019-04-07 16:38:02 +01:00
Aidan Woods
74bba0b2fa
rtrim non hard breaking lines 2019-04-07 16:38:02 +01:00
Aidan Woods
fc37ad11ed
Tabs shouldn't break thematic breaks 2019-04-07 16:38:02 +01:00
Aidan Woods
4e9a0113c3
Thematic breaks can't have an indent of more than 3 2019-04-07 16:38:02 +01:00
Aidan Woods
82c981657d
Require Inlines to provide a best plaintext rendering
This allows markdown to be parsed "inside" the alt
attribute of an image, and then the best plaintext
can be used as the rest.
This improves CommonMark compliance.
2019-04-07 16:38:02 +01:00
Aidan Woods
576a2c4519
Generalise line parsing to return Inlines before applying state 2019-04-07 16:38:01 +01:00
Aidan Woods
083ad582c7
State management
Decouple state from final rendering
Restore initial state after parsing
2019-04-07 16:38:01 +01:00
Aidan Woods
c9388cb5c2
Make use of line name instead of lineElements 2019-04-07 16:38:01 +01:00
Aidan Woods
bb8a16ad81
Remove useless line method
This will be achievable by directly restricting enabled Components
2019-04-07 16:38:01 +01:00
Aidan Woods
7f526c07a0
Indent offset is encompassed in Lines object 2019-04-07 16:38:01 +01:00
Aidan Woods
366600034c
This isn't used and is derivable from the indent 2019-04-07 16:38:01 +01:00
Aidan Woods
6add0ea877
Remove useless variables 2019-04-07 16:38:00 +01:00
Aidan Woods
dac6b01d1a
Remove meaningless interrupt check
Interrupted implies previousEmptyLines > 0 in incoming Context
2019-04-07 16:38:00 +01:00
Aidan Woods
6f5780abfd
Improve Link API 2019-04-07 16:38:00 +01:00
Aidan Woods
2757274854
Constant arrays to static vars for PHP 5.5 2019-04-07 16:38:00 +01:00
Aidan Woods
37895448ba
Fix PHP 5.6 bug 2019-04-07 16:38:00 +01:00
Aidan Woods
6f1bc7db14
Fix pre PHP7 closure-as-property closure syntax 2019-04-07 16:38:00 +01:00
Aidan Woods
e4ed4da626
More keyword related fixes for pre PHP 7 2019-04-07 16:38:00 +01:00
Aidan Woods
351a68a14c
Remove some return type hints that I missed 2019-04-07 16:37:59 +01:00
Aidan Woods
a9aa7e7aae
Test on PHP 5.5 and 5.6
Issue on pre PHP 7 may be to do with method name and not call syntax as
suspected
2019-04-07 16:37:59 +01:00
Aidan Woods
f8003dcded
Remove debug lines 2019-04-07 16:37:59 +01:00
Aidan Woods
e6e24a8d0d
Rewrite to use new internals 2019-04-07 16:37:58 +01:00
Aidan Woods
36cfb21908
Remove no longer needed parts of core class 2019-04-07 16:37:58 +01:00
Aidan Woods
dbdbda52a8
Make Parsedown non-extendable and remove comment header 2019-04-07 16:37:58 +01:00
Aidan Woods
114eb0bc5b
Add required imports 2019-04-07 16:37:57 +01:00
Aidan Woods
a286033f52
Implement UrlTag 2019-04-07 16:37:57 +01:00