typeset icon indicating copy to clipboard operation
typeset copied to clipboard

Refactored code for use as a library.

Open frobnitzem opened this issue 7 years ago • 3 comments

The main files were moved into the src directory, and Typeset was removed in favor of the classes "LineBreak," "LinkedList," and the function "BreakLines." It seems that LinkedList could be written to use arrays...

Top-level wrapper functions from browser-assist were moved into src/typeset.js which is now called like:

ret = typeset(text, measure_a_line, 'justify', [350], 3);
spans = gen_html(ret)
$('#browser-assist').append(spans[0]);
$('#browser-assist + ul').append(spans[1].map(function(w) {
    return "<li>"+w.toFixed(3)+"</li>";
}).join(""));

ideally, the more advanced ones used in flatland will follow later.

frobnitzem avatar Mar 19 '17 04:03 frobnitzem

Do your changes have any effects on reported bugs?

  1. poor line-breaking in flatland demo
  2. line-length setting doesn't seem to work
  3. demerits value 100 or 3000?

PhilterPaper avatar Mar 24 '21 22:03 PhilterPaper

I haven't reviewed these in detail @PhilterPaper, but the typical definition of "refactoring" code in programmer jargon would mean that no, this has no affect on reported bugs. When you refactor code you basically shuffle things around to different places or making various structural changes to the code, but the expected input and output is the same.

Of course refactoring can fix bugs (or introduce new ones), but the goal of a refactor is to not change the function while improving the code health.

alerque avatar Mar 25 '21 06:03 alerque

These are maintainability improvements, so that changes to the codebase can be more isolated and require less working memory for library developers and users.

frobnitzem avatar Aug 12 '22 15:08 frobnitzem