-
Notifications
You must be signed in to change notification settings - Fork 299
Version 0.60.0 Changes
The extent of the changes and optimizations made it impossible to use the slow @Deprecated
annotation with eventual removal in all cases.
- Major reorganization and code cleanup of implementation for next version 0.60.0
-
Formatter implementation is now part of core implementation in
flexmarkmodule -
Formatterimproved with more options including wrapping text to margins.- added ability to track and map source offset(s) to their index in formatted sequence. This feature allows editor caret position preservation across formatting operation.
- Offset tracking unified using
TrackedOffset. Used byMarkdownParagraphfor text wrapping andMarkdownTablefor table formatting and able to handle caret position during typing and backspace editing operations which are immediately followed by formatting or the edited source.
-
Tests cleaned up to eliminate duplication and hacks
-
flexmark-test-utilmade reusable for other projects. Having markdown as the source code for tests is too convenient to have it only used forflexmark-javatests. -
Optimized
SegmentedSequenceimplementation using binary trees for searching segments and byte efficient segment packing. Parser performance is either slightly improved or not affected but allows usingSegmentedSequencesfor collectingFormatterandHtmlRendereroutput to track source location of all text with minimal overhead and double the performance of old implementation. -
new implementation of
LineAppendableused for text generation in rendering:-
can use
SequenceBuilderto generateBasedSequenceresult with original source offsets for those character segments which come from the source. This allows round trip source tracking from Source -> AST -> Formatted Source -> Source throughout the library.As an added bonus using the appendable makes formatting to it 40% faster than previous implementation and 160 times (yes times) more efficient in memory use. For the test below, old implementation allocated 6GB worth of segmented sequences, new implementation 37MB. The % overhead is four times greater but that is after a 43 fold reduction in total overhead bytes, old implementation needed 342MB of overhead, new implementation 8MB.
As a result of increased efficiency, two additional files of about 600kB each can be included in the test run and only add 0.6 sec to the formatter run time.
Tests run on 1141 markdown files from GitHub projects and some other user samples. Largest was 256k bytes.
Description Old SegmentedSequence New Segmented Sequence New LineAppendable Total wall clock time 13.896 sec 9.672 sec 8.344 sec Parse time 2.402 sec 2.335 sec 2.297 sec Formatter appendable 0.603 sec 0.602 sec 0.831 sec Formatter sequence builder 7.264 sec 3.109 sec 1.772 sec The overhead difference is significant. The totals are for all segmented sequences created during the test run of 1141 files. Parser statistics show requirements during parsing and formatter ones are only for formatting of them while accumulating the text as a segmented sequence.
Description Old Parser Old Formatter New Parser New Formatter New LineAppendable Bytes for characters of all segmented sequences 917,016 6,029,774,526 917,016 6,029,774,526 37,663,196 Bytes for overhead of all segmented sequences 1,845,048 12,060,276,408 93,628 342,351,155 8,204,796 Overhead % 201.2% 200.0% 10.2% 5.7% 21.8% -
-
- Doc:
BasedSequence,SegmentedSequenceandBasedSequenceBuilderchanges. - Doc:
LineAppendableand usingSequenceBuilderas an appendable target for it to accumulate rendered text with source information.
-
Break: split out generic AST utilities from
flexmark-utilmodule into separate smaller modules. IntelliJ IDEA migration to help with migration from 0.50.40 will be provided where needed if the package or class is changed.com.vladsch.flexmark.utilwill no longer contain any files but will contain the separate utilities modules withflexmark-utilsmodule being an aggregation of all utilities modules, similar toflexmark-all-
ast/classes toflexmark-util-ast -
builder/classes toflexmark-util-builder -
collection/classes toflexmark-util-collection -
data/classes toflexmark-util-data -
dependency/classes toflexmark-util-dependency -
format/classes toflexmark-util-format -
html/classes toflexmark-util-html -
mappers/classes toflexmark-util-sequence -
options/classes toflexmark-util-options -
sequence/classes toflexmark-util-sequence -
visitor/classes toflexmark-util-visitor
-
-
Convert anonymous classes to lambda where possible.
-
refactor
flexmark-utilto eliminate dependency cycles between classes in different subdirectories. -
Break: delete deprecated properties, methods and classes
-
Add:
org.jetbrains:annotations:18.0dependency to have@Nullable/@NotNullannotations added for all parameters. I use IntelliJ IDEA for development and it helps to have these annotations for analysis of potential problems and use with Kotlin. -
Break: refactor and cleanup tests to eliminate duplicated code and allow easier reuse of test cases with spec example data.
-
Break: move formatter tests to
flexmark-core-testmodule to allow sharing of formatter base classes in extensions without causing dependency cycles in formatter module. -
Break: move formatter module into
flexmarkcore. this module is almost always included anyway because most extension have a dependency on formatter for their custom formatting implementations. Having it as part of the core allows relying on its functionality in all modules. -
Break: move
com.vladsch.flexmark.specandcom.vladsch.flexmark.utilinflexmark-test-utiltocom.vladsch.flexmark.test.specandcom.vladsch.flexmark.test.utilrespectively to respect the naming convention between modules and their packages. -
Break:
NodeVisitorimplementation details have changed. If you were overridingNodeVisitor.visit(Node)in the previous version it is nowfinalto ensure compile time error is generated. You will need to change your implementation. See comment in the class for instructions.ℹ️
com.vladsch.flexmark.util.ast.Visitoris only needed for implementation ofNodeVisitorandVisitHandler. Converting all anonymous implementations ofVisitHandlerto lambdas results in removal of all imports forVisitor.- Fix: remove old visitor like adapters and implement ones based on generic classes not linked to flexmark AST node.
- Deprecate old base classes:
-
com.vladsch.flexmark.util.ast.NodeAdaptedVisitorsee javadoc for class com.vladsch.flexmark.util.ast.NodeAdaptingVisitHandlercom.vladsch.flexmark.util.ast.NodeAdaptingVisitor
-