currently software engineer at ๐ sourcegraph.
previously wrote code at ๐ riot games, ๐ก sumus, ๐ข rtrade, the ๐ bc genome sciences centre, and ๐๏ธ nwplus. studied mathematics at ๐ ubc, where i helped run ๐ ubc launch pad.
๐ Opinionated Markdown formatter, featuring semantic line breaks
Home Page: https://bobheadxi.dev/semantic-line-breaks/
currently software engineer at ๐ sourcegraph.
previously wrote code at ๐ riot games, ๐ก sumus, ๐ข rtrade, the ๐ bc genome sciences centre, and ๐๏ธ nwplus. studied mathematics at ๐ ubc, where i helped run ๐ ubc launch pad.
as titled
./dev readable fmt TEST.md --log-level DEBUG
results in:
ERROR failed to render 'TEST.md', aborting: ReferenceError: document is not defined
after adding log.error(err.stack);
to lib/walk.ts
I'm getting:
ERROR fmt: ReferenceError: document is not defined
at Object.decodeEntity [as default] (https://jspm.dev/npm:[email protected]/decode-entity!cjs:12:14)
at value (https://jspm.dev/npm:[email protected]/dist/parse!cjs:1448:76)
at go (https://jspm.dev/npm:[email protected]/dist/parse!cjs:810:13)
at main (https://jspm.dev/npm:[email protected]/dist/parse!cjs:800:11)
at Object.write (https://jspm.dev/npm:[email protected]/dist/parse!cjs:744:5)
at subcontent (https://jspm.dev/npm:[email protected]/_/4550b33d.js:133:17)
at subtokenize (https://jspm.dev/npm:[email protected]/_/4550b33d.js:54:23)
at postprocess (https://jspm.dev/npm:[email protected]/dist/postprocess!cjs:10:11)
at fromMarkdown (https://jspm.dev/npm:[email protected]!cjs:32:28)
at parse (https://jspm.dev/npm:[email protected]!cjs:12:12)
ERROR failed to render 'TEST.md', aborting: ReferenceError: document is not defined
As a workaround, I applied this patch:
diff --git a/readable.ts b/readable.ts
index b44ed82..1cf867a 100644
--- a/readable.ts
+++ b/readable.ts
@@ -7,6 +7,12 @@ import check from "./cmd/check.ts";
import fmt, { FmtOptions } from "./cmd/fmt.ts";
import setupLogger from "./lib/setupLogger.ts";
+import { DOMParser } from "https://deno.land/x/deno_dom/deno-dom-wasm.ts";;
+
+const parser = new DOMParser();
+const doc = parser.parseFromString("<!DOCTYPE html><html><head></head><body></body></html>", "text/html");
+globalThis.document = doc;
+
const cli = cac("readable")
.version(READABLE_VERSION)
.help()
which allowed me to execute readalbe
successfully.
I don't know if this is an acceptable long term fix or not.
It seems like for some reason a browser versions of dependencies are pulled in and it would be probably better to fix that problem.
TSIA.
To reproduce (file named hir.md
):
For example, the contents of individual items (e.g. modules, functions, traits, impls, etc) in the HIR are not immediately accessible in the parents.
run
readable fmt hir.md
Result:
For example, the contents of individual items (e.g.
modules, functions, traits, impls, etc) in the HIR are not immediately accessible in the parents.
Expected result:
File not to change.
Issue occurs in master commit 8e53ead and v2.2
release.
$ deno install --unstable --allow-read --allow-write https://deno.land/x/readable/readable.ts
Download https://deno.land/x/readable/readable.ts
Warning Implicitly using latest version (v0.2.0) for https://deno.land/x/readable/readable.ts
Download https://deno.land/x/[email protected]/readable.ts
Download https://deno.land/x/[email protected]/deps/cac.ts
Download https://deno.land/x/[email protected]/cmd/fmt.ts
Download https://deno.land/x/[email protected]/version.ts
Download https://deno.land/x/[email protected]/cmd/check.ts
Download https://deno.land/x/[email protected]/markdown/format.ts
Download https://deno.land/x/[email protected]/lib/walk.ts
Download https://deno.land/x/[email protected]/lib/diff.ts
Download https://deno.land/x/[email protected]/deps/fs.ts
Download https://deno.land/x/[email protected]/deps/remark.ts
Download https://deno.land/x/[email protected]/plugins/mod.ts
Download https://deno.land/x/[email protected]/deps/colors.ts
Download https://deno.land/x/[email protected]/deps/diff.ts
Download https://deno.land/x/[email protected]/plugins/readable/mod.ts
Download https://deno.land/x/[email protected]/plugins/thirdparty/mod.ts
Download https://deno.land/x/[email protected]/plugins/readable/reflow.ts
Download https://deno.land/x/[email protected]/plugins/thirdparty/stringify.ts
Download https://deno.land/x/[email protected]/plugins/thirdparty/frontmatter.ts
Download https://deno.land/x/[email protected]/markdown/ast.ts
error: Import 'https://deno.land/x/[email protected]/version.ts' failed: 404 Not Found
at https://deno.land/x/[email protected]/readable.ts:1:0
$ deno --version
deno 1.11.1 (release, x86_64-unknown-linux-gnu)
v8 9.1.269.35
typescript 4.3.2
we should have an editor-agnostic format-on-save service. blocked by #3
readable watch ...
or:
readable fmt -watch ...
Hi, just a note that there's no LICENSE file in this repository that I can find - it would be great if this was released under an open source licence!
e.g. per-file, per-directory (globbing?), output in stdout/disk, maybe even input stdin
readable fmt
readable check
Right now it just looks really bad
:)
File to reproduce (minimal.md):
We want to convert this into an error. In some cases, there may be an
existing error for this scenario. In others, we will need to allocate a
fresh diagnostic code. [Instructions for allocating a fresh diagnostic
code can be found here.](./diagnostics/diagnostic-codes.md) You may want
to mention in the extended description that the compiler behavior
changed on this point, and include a reference to the tracking issue for
the change.
Running
readable check minimal.md
On master and v2.2 it throws error:
ERROR failed to render '/home/muradb/personal/rustc-dev-guide/minimal.md', aborting: Error: Cannot take length of multi-line node '[object Object]'
Error: Cannot take length of multi-line node '[object Object]'
at nodeLength (file:///home/muradb/personal/readable/markdown/ast.ts:92:16)
at ReflowParagraphState.addRawNode (file:///home/muradb/personal/readable/plugins/readable/reflow.ts:84:31)
at processParent (file:///home/muradb/personal/readable/plugins/readable/reflow.ts:288:41)
at reflowParagraph (file:///home/muradb/personal/readable/plugins/readable/reflow.ts:321:3)
at visit (file:///home/muradb/personal/readable/plugins/readable/reflow.ts:335:9)
at file:///home/muradb/personal/readable/plugins/readable/reflow.ts:338:42
at Array.forEach (<anonymous>)
at visit (file:///home/muradb/personal/readable/plugins/readable/reflow.ts:338:23)
at transformer (file:///home/muradb/personal/readable/plugins/readable/reflow.ts:344:5)
at wrapped (https://jspm.dev/npm:[email protected]!cjs:21:19)
Upon further having some console.log
s in nodeLength
function, it's clear that the error occurs because of link element in the example, specifically when it tries to check for if node is literal:
Line 90 in 8e53ead
theres still a fault in the heuristic where we don't break on every sentence, just those that aren't wicked short. however, if we get a short sentence followed by a long boi you get two super long sentences:
deno run readable-demo.ts fixture2
# Document
hello world! this is a document. here is a sentence.
and here is another `sentence`! with a [a link](https://bobheadxi.dev) and **emphasis [bold link](https://github.com/bobheadxi)** and *italics* and ~~strike~~ and a ![cute image](https://bobheadxi.dev/assets/images/profile.jpg).
should be:
# Document
hello world! this is a document. here is a sentence.
and here is another `sentence`!
with a [a link](https://bobheadxi.dev) and **emphasis [bold link](https://github.com/bobheadxi)** and *italics* and ~~strike~~ and a ![cute image](https://bobheadxi.dev/assets/images/profile.jpg).
Simple plug-and-play usage in GitHub actions, probably just for checking. Blocked by #3
Observed problems, named by best guess at what might be causing the issue
Hello,
I would like to use readable, but the mardown format miss formats my citations and other stuff. can I just deactivate it?
This is similar to #4, but instead of describing just the goals and motivation of the project (the "what" and "why"), this issue focuses on the "how".
Specifically, it would be nice to have an overview of that the code does and how it works. This documentation could live in README.md
or in CONTRIBUTING.md
(or both). I would expect at least a link to https://github.com/bobheadxi/readable/blob/main/plugins/readable/reflow.ts, which, if I understand correctly, is core of the project.
input:
1. use the Golang [abstract syntax tree parser](https://golang.org/pkg/go/ast/)
to identify "selectors", such as `my.value` (this approach did not have the
`SELECT` syntax described early - an example of the initial proposal's syntax
was simply `container.count - 1`. In this case, `container.count` is a valid Go selector
that would be recognised by the AST parser)
2. evalaute the selectors using the `gojsonq` library
3. 3. perform expression arithmetic using the `govaluate` library with the selected
values as [parameters to the expression](https://github.com/Knetic/govaluate#how-do-i-use-it)
got:
1. use the Golang [abstract syntax tree parser](https://golang.org/pkg/go/ast/)
to identify "selectors", such as `my.value` (this approach did not have the `SELECT` syntax described early - an example of the initial proposal's syntax was simply `container.count - 1`.
In this case, `container.count` is a valid Go selector that would be recognised by the AST parser) 2.
evalaute the selectors using the `gojsonq` library 3.
perform expression arithmetic using the `govaluate` library with the selected values as [parameters to the expression](https://github.com/Knetic/govaluate#how-do-i-use-it)
definitely wrong :( related: #7
console.log
is hack, should find a better logger for Deno
Readable is looking very cool for my use case of linting Markdown file styling. My ideal interaction pattern would be to add Readable's docker container as a pre-commit hook so it ran on every user's commit. Would you be interested in supporting that? It's a pretty minimal addition to this repo, e.g. two ids, readable-fmt
and readable-check
.
Instructions on how to set up:
https://pre-commit.com/#docker_image
Example of actionlint
's docker image being set up as a pre-commit hook: https://github.com/rhysd/actionlint/blob/main/.pre-commit-hooks.yaml
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.