- Handle newlines in emphasis and strong emphasis.
- Handle code blocks and HTML blocks with missing closer.
- Strip trailing blank lines when parsing HTML blocks.
- Fix corner cases in info strings of code fences.
- Try to avoid escaping & and < when they are not problematic.
- Escape non-breaking space.
- Format lists as loose lists.
- Only indent inline raw HTML when it can actually be parsed as a
paragraph-interrupting HTML block.
- When parsing starting markers, consider the rest of the line to be in a new
paragraph after one marker is parsed.
- FmtCodec: Escape info string in fenced code blocks.
- FmtCodec: Use "_" as emphasis marker also after end of emphasis or strong emphasis.
- Avoid reformatting "- - *" as "- - -"; the former is a 3-level list with no
content, the latter is a thematic break.
- Escape "~~~" at the start of line.
- When handling escapes inside ATX headings, use "i == 0" as a condition for
start of line, since we are actually not at the literal start of line after
writing the heading starter.
- Fix the definition of Unicode punctuations to be consistent with the spec.
- Only escape "!" when followed by a link.
- Only escape "#" when it is either at the start of line in a paragraph and
introduce an ATX heading, or is at the end of the line in an ATX heading and
can be parsed as the optional ATX heading closer.
- Escape "-" and "+" if and only if they can introduce a bullet list.
- Escape "." and ")" if and only if they come after a number and can introduce
an ordered list.
- Escape ">" when it can introduce blockquote.
- Escape spaces and tabs at start and end of line.
This avoids a dependency on the html package, which has a huge entity table.
The pkg/md package is not used by Elvish now, but its impact on the binary size
can be measured by exposing md.Render as a builtin function.
- With the dependency on the html package, Elvish's binary size would increase by
206KiB.
- Without the dependency, the binary size would only increase by 125KiB.
- Use a Codec interface to specify output format.
This gives more control over how output is built, and will make it possible to
build a terminal renderer.
- Refactor block tree logic into its own type.
- Handle the opening and closing of list containers in one place.
- Use lookahead to implement the rule allowing only one blank line to start a
list item.
- Remove handling for non-\n line endings.
This is required by the spec, but there is no test for it. It was also not
handled consistently before; if there is a need, it is easier to just
normalize the line ending at the very beginning rather than handling it
everywhere.
Entities in link destination and title need to be handled as part of the parsing
procedure, instead of after it. The spec doesn't have test cases for this, so
added new supplemental test cases.
Entity support in autolinks also don't have test cases in the spec, so add a
supplemental test case too.
Indented code blocks and link reference definitions are used a lot in other
sections, and they used to be skipped by matching the markdown with regexp
patterns. However, this has some false positives, so list the individual example
IDs instead.
I noticed this when testing my `help` command and noticed that
`help builtin:` produced three lines of "usage" text that did not
include a function or variable name.
Glob expansion should use os.Lstat rather than os.Stat so that broken
symlinks don't stop glob expansion. It's not the place of glob expansion
to decide if a particular path is good.
The symlink test cases and logic were borrowed from
pkg/mods/path/path_test.go.
Fixes#1240
This is used in ttyshots to get deterministic outputs.
This command is prefixed with - since I'd like to eventually move rand and
randint into their own module, so this command will be moved too.
Styled text is not supposed to "inherit" the current SGR styling context when
written to the terminal. This has always been the intention, but not correctly
implemented. This commit fixes that for both styled segments and styled texts.
Tests are amended to account for the difference in the output.
With context insensitivity correctly implemented, there is now no need for a
"default" color. It is functionally equivalent to a lack of color.
The parsing of SGR still needs to be aware of the codes 39 (default foreground)
and 49 (default background), but these codes are now translated into FgDefault
and BgDefault, which resets the foreground and background color fields.
The main benefits of this change are:
1) It uses a hermetic "home" directory with a known command and location
history. Which means it no longer depends on the interactive history
and directory layout of the person creating the ttyshot. Which also
means it no longer leaks the private history of anyone creating a
ttyshot. This produces reproducible results when updating ttyshots.
2) The user no longer has to augment the ttyshot by manually adding the
output of the commands to the generated HTML file. A process that is
error prone. The output of the commands that generate the ttyshot is
now captured and automatically included in the resulting HTML.
3) It makes it trivial to recreate every ttyshot. Simply execute these
commands:
```
make ttyshot
for f [website/ttyshot/**.spec] { put $f; ./ttyshot $f }
```
4) It makes it easy to introduce new "ttyshot" images by creating a
shell session "spec" file. This makes it easy to replace the existing
"```elvish-transcript...```" examples with ttyshots in order to
ensure a consistent representation and visual consistency with the
transcripts that are currently generated as ttyshots.
The downside of this change is the introduction of a dependency on the
Tmux application. But that seems reasonable since Tmux is a mature
application available on Linux, macOS, BSD, and probably every other
UNIX like OS we care about. Note that generating the Elvish
documentation already depends on similar apps such as Pandoc.
Related #1459
The logs are not useful anyway since the reason is invariably that the client
has already closed the connection.
Moreover, timing in the shutdown sequence causes fluctuation in test coverage;
removing this log eliminates the fluctuation.
There is no need to enumerate namespaces separately, since namespaces are also
variables. The only exceptions are "e:" and "E:", which are handled as special
cases now.
In addition to fixing the encoding bugs standardize on \xNN notation for
bytes rather than \uNNNN; e.g., \x00 rather than \u0000.
Also, update the documentation for double-quoted strings to include the
\e sequence.
Fixes#1528
It turns out that the "small word" abbreviation mechanism I added isn't
really what I, or most users, want. What users really want, at least
most of the time, is the Fish shell abbreviation behavior of expanding
an abbreviation only in the command head position.
Resolves#1472
Qualified imports of pkg/parse outnumber unqualified (66 to 1). Improve
consistency, and clarity, by changing the dot (unqualified) imports of
that package symbols to qualified.
Qualified imports of pkg/ui outnumber unqualified (82 to 1). Improve
consistency, and clarity, by changing the dot (unqualified) imports of
that package symbols to qualified.
Qualified imports of pkg/tt outnumber unqualified (27 to 24). Improve
consistency, and clarity, by changing the dot (unqualified) imports of
that package symbols to qualified.
Qualified imports of pkg/testutil outnumber unqualified (55 to 7). Improve
consistency, and clarity, by changing the dot (unqualified) imports of
that package symbols to qualified.
The PureEvaler abstraction made things unnecessarily complex; it's better to
just create a real Evaler for tests is pretty.
The Evaler has a new ReplaceBuiltin method to make it easier to construct the
expected test result.
If a buffer (or notes buffer) hasn't appeared, it means that the app is not in
some intended state. Subsequent tests are unlikely to be meaningful, and may run
into race conditions.
A lot of existing code already uses TestBuffer to ensure that a certain state is
reached, and making failures fatal also suits this usage better.
This fixes#1507.
This allows the build commands in Makefile and tools/buildall.sh to be
simplified.
Official reproducible builds are now handled as a build variant, and the command
in Makefile no longer tries to produce reproducible builds.
Instructions in PACKAGING.md have been completely rewritten.
Remove SetupGlobal and Sanitize and replace them with a SetupForEval, which is
similar to Setup, but called before evaluating code and returns a function to
call after evaluating code.
This was extracted from https://github.com/elves/elvish/pull/1326. It
augments that change by honoring $E:PATHEXT and some other
minor improvements. This matches the behavior of the Go stdlib
os/exec.LookPath() function that is used to decide if what has been typed
(in a non-completion context) represents an external command.
cmp.Diff panics when comparing a struct that has unexported fields and no String
or Equal method, so change some structs to either export all their fields or
have an Equal method.
This fixes#1136.
There was a recent question for which the answer was to use the
`-compileonly` flag but the user didn't realize that because there was
no mention on https://elv.sh/ref/command.html. Similarly, other flags,
like `-decpreation-level`, would benefit from more verbiage than shown by
`elvish -help`.
* Require at least one of "except" or "finally" to be present. This fixes#1424.
* Rename "except" to "catch". The former will be deprecated from 0.18.0. This
addresses #1497.
- Introduce nodePath to store the complete path to the leaf node.
- Introduce a nodesMatcher abstraction to do pattern matching on nodePath.
Parse tree matching previously requires deeply nested if statements to walk
multiple levels of the tree and (optionally) check the property of nodes. These
are replaced by a single "if np.match(...)", with a single level of nesting.
Instead of putting all possible flags in prog.Flags, flags are now registered by
the individual subprograms. The 3 flags -sock, -db and -json are shared by
multiple subprograms and still handled by the prog package.
This new design allows separating the support for -cpuprofile into a separate
subprogram, which is no longer included by the default entry point, making the
binary slightly smaller. A new entrypoint "withpprof" is created.
Also include the LSP subprogram in the nodaemon entry point.
It was an oversight to make them encode codepoints; they were always intended to
be equivalent to their Go counterparts, which encode bytes and can be used to
write arbitrary byte sequences that are not necessarily valid UTF-8 sequences.
With the previous fix, the parsing algorithm could still backtrack without
making progress given slightly more sophisticated input (see added testdata for
an example).
Instead of trying to parse a temporary assignment when it *could* be one, only
parse it when we are sure that it is. This should now truly fix the issue.
The parsing function for Form first tries to parse a temp assignment, and
backtracks when an assignment cannot be parsed. When the input is "(" repeated n
times, each level of Form parsing will first try to parse the rest of the code
as an assignment and then backtrack, without making any progress. This results
in a call tree with a branching factor of 2, hence the O(2^n) complexity.
The fix is to first try to parse a head instead, and only try to parse it as a
temp assignment if it does contain "=". This fixes this particular pathological
case, although I'm not 100% sure it eliminates all possibilities of O(2^n) time
complexity.
With the introduction of the "tmp" special command, the current syntax for
temporary assignments will be deprecated and eventually go away, which will
eliminate all backtracking in the parser. In the meanwhile, this fix may be good
enough.
This case was discovered with fuzzing support in Go 1.18. Also add the fuzzing
test data.
Also remove support for the "name" field tag from eval.scanOptions - it's not
used anywhere and the use case it was intended for is handled by CamelToDashed.
- Don't require creating a Getopt object in the API.
- Add a new Parse function, and rename the existing method to Complete.
- Add an Unknown field to Option to indicate unknown options.
- Rewrite the tests.
- Numerous stylistic changes.
- Revise the introduction section.
- Link to the notes on commands taking value inputs from all such commands.
- Revise the doc on the "all" command.
- Revise references to the builtin module from the language reference.
* docs(effective-elvish): follow same style as other docs
e.g., https://elv.sh/ref/language.html
* docs(builtin): ref from take to drop
* docs(language): remove mention of :up and :down ns
* docs(fundamentals): update to new lambda format
* docs(tour): update to new lambda syntax
* docs(builtin): update to new lambda syntax
* docs(language): update to new lambda syntax
* docs(unique-semantics): update to new lambda syntax
* docs(tour): fix typo
* Revert "docs(effective-elvish): follow same style as other docs"
This reverts commit db4306a400c61f5f7b6acec7a1e1f39feb9b1ba0.
https://github.com/elves/elvish/pull/1457#discussion_r775102178
The existing `edit:add-var` documentation incorrectly implies the `$init`
value is optional. It also doesn't include any examples that are useful
in practice. This addresses both shortcomings.
* Remove a superfluous line break in the equivalent Elvish code.
* Keep code in transcripts on the same line to be correctly highlited.
* Add another example using digit-only argument names.
The `AnyError` placeholder error can cause tests to succeed for errors
other than what was expected. That is, the use of `AnyError` can mask
bugs in a unit test. So replace it with the specific error, or error type,
the test expects to be raised.
This does not remove the anyError structure because it is used in
the TestCase.DoesNotCompile() method. To keep the size of this change
as small as possible I want to defer updating that use to a separate
change. However, remove the public AnyError var so future test writers
don't attempt to use it.