Giter VIP home page Giter VIP logo

ourbigbook / ourbigbook Goto Github PK

View Code? Open in Web Editor NEW
55.0 3.0 5.0 7.66 MB

https://OurBigBook.com source code + a compatible local CLI static wiki generator and markup language to write complex structured wikis/books/blogs with reference implementation in JavaScript.

Home Page: https://ourbigbook.com

License: GNU Affero General Public License v3.0

JavaScript 84.59% HTML 0.53% Shell 0.62% SCSS 2.19% Vim Snippet 0.06% TypeScript 11.39% TeX 0.13% Vim Script 0.33% Python 0.15%
static-site-generator markup-language javascript nodejs wiki

ourbigbook's Introduction

OurBigBook

https://ourbigbook.com source code + a compatible local CLI static wiki generator and markup language to write complex structured wikis/books/blogs with reference implementation in JavaScript.

The real README is of course README.bigb

A rendered version can be seen at: https://docs.ourbigbook.com

ourbigbook's People

Contributors

ourbigbook-admin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ourbigbook's Issues

Infinite cross reference recursion in header title leads to stack overflow

Infinite xref header recursion: asciidoctor/asciidoctor#3543

Simple solution: forbid x in titles, pass down context from parent.

But this solution is not ideal, since linking from image and video titles is immensely useful.

The better solution is to actually do full loop detection, and render the links as plaintext on the cross references: #45

Already added a commented out test in tests.js.

Making this fully generic is however annoying, because you have to delay ID calculation in general with an x dependency tree, you can't just do it top-to-bottom immediately, e.g.

\Image[asdf]
{title=asdf}

\Image[qwer]
{title=\x[zxcv-asdf]}

\Image[zxcv]
{title=zxcv \x[asdf]}

the qwer image needs zxcv to resolve its title before it can resolve its own ID.

Simpler solution that covers main use case: allow cross links only from non-headers to headers. Works because header IDs are calculated on an earlier pass due to the parent= implementation.

Boolean options

E.g. to allow just \x[mysect]{full} rather than \x[mysect]{style=full} and \video[asdfqwer]{youtube}

Allow a paragraphs to start with block code followed by plain text inside same paragraph.

In:

a

``
b
``
c

d

the c falls off to the left because it is not wrapped in a div.

cirodown ef69b21 after the refactor to allow left hover IDs on paragraphs and allow code blocks inside paragraphs.

Tried to fix with: https://github.com/************/cirodown/tree/phrase-after-block but then minimized README:

\h[1][a]

\h[2][b]

\h[3][c]

\include[not-readme]

\include[not-readme-2]

\h[2][d]

fails wtih:

error: line 7 column 1: skipped a header level from 2 to 4

fuck, include trouble is often insanely hard.

OK, from --show-ast it is because headers are getting put inside a paragraph of their own, which is wrong and falls on another bug: #4

Insane tables

Not super critical since tables are relatively rare, but maybe would be good.

|| h1
|| h2
|| h2

| 1 1
| 1 2
| 1 3

| 2 1
| 2 2
| 2 3

  On same item due to indent.

| 3 1
| 3 2
| 3 3

The | is tokenized exactly like insane list items, but we have to think about how to deal with the \n\n.

Image media management pipeline

cirodown.json can contain media source entries:

"media-providers": {
  "github": {
    "default-for": ["image"], // "all" to default for both image, video and anything else
    "path": "data/media/",  // data is gitignored, but should not be nuked like out/
    "remote": "************/cirodown-media", // calculated default from this projects name
    "type": "github" // default from name
  },
  "local": {
    "default-for": ["video"],
    "path": "media/",
    "src": "************/cirodown-media",
    "type": "local" // default from name
  },
  "youtube": {}
}

A specific provider for one Image can be selected with {provider=}.

If the src of Image does not start with https?:// then the default media-source is used, and that path is modified according to the selected provider:

  • type: local: added to the same mechanism that uploads HTML content, e.g. in the current git repo
  • type: github: a locally cloned GitHub repo at the latest version. Clone it if not yet cloned. Could be a submodule, but not necessary if you never rename/delete media (so that older versions work), cirodown handles the cloning for you.

default-for is case agnostic on the first character, so that using default-for: "image" works on both Image and image. The default-for` value must always start with a lower case characters.

Advantages:

  • when building the HTML, all media that is not downloaded locally is first downloaded locally, and the local media URLs are used so you can view and develop the website without the internet.

    Media that starts with https? just gets wget downloaded to the out/media cache

    The update is done on the fly only if there is one missing media path locally, to avoid web usage every time. You can use --force-download to always check if we are at latest.

    This will also enable fully embedding images with --html-embed to produce fully self contained documents.

  • when pushing, local media that was used in the build gets committed and pushed automatically to remote.

    This is especially important when we start doing media generation from source code, e.g. images from dot files.

cirodown c167066 actually already has a video source: youtube. That one should be the default actually, so if you write an URL without https? it uses youtube by default, and for local you need {provider=local}.

LaTeX output

Fuck PDF.

We have an AST that gets rendered to HTML currently. Just render to LaTeX instead.

Javascript redirect for fragments

For toplevel IDs on a page, we can generate redirects easily: #42

Or in other words, allow the source of redirects in cirodown.json to be a non-toplevel IDs.

With JavaScript, we can too though, just feed a map of input/output #old-ide to #new-id to all pages, and redirect in case it gets hit at page load.

Nest headers in AST

This will allow for some cool things like clicking to collapse sections with JavaScript.

Insane headers

Up to newline:

== 1 My h1

== 2 My `h2`

Or do we go with:

= My h1

== My `h2`

The problem with that approach is that when we get huge header levels, insane headers become useless.

The upside is that it covers the common case more readily, up to 4 same number of chars, and up to 6 still well recognizable. Users can then use insane for more than 6? Dillemas.

Parse youtube URLs

Extract source and t= from the youtube url itself. Also handle youtu.be urls. This way silly users can just copy paste their stuff.

Editor contenteditable div innerText expands two enters to three newlines

At 3473e7f patch the editor:

diff --git a/editor.html b/editor.html
index 773456a..9850154 100644
--- a/editor.html
+++ b/editor.html
@@ -48,6 +48,7 @@ html, body {
 let input_elem = document.getElementById('input');
 let output_elem = document.getElementById('output');
 input_elem.addEventListener('input', function() {
+  console.log(JSON.stringify(input_elem.innerText));
   output_elem.innerHTML = cirodown.convert(
       input_elem.innerText, {'body_only': true});
 }, false);

and we observe that an input:

a<enter><enter>b

generates 3 newlines instead of the expected 2:

"a\n\n\nb"

ID ordering must do depth first not breadth first

At cirodown 3254f4a , we can get surprising ID orders e.g.:

\M[1]

\q[\M[2]]

\M[3]

produces IDs that render on the document in order 1 3 2 rather than the desired 1 2 3.

This is because the \q is only searched for IDs after the toplevel \M[3].

Generally this is not a big problem because linkable things stay on toplevel, but still, should be fixed.

Maybe this will also completely break math macro definitions across math blocks: https://github.com/************/cirodown/blob/73b52c4ce0e50945724a843ac12212faa2ded4bf/README.ciro#L870

Publish as single page as in an --html-single-page build

cirodown.json:

"publish": {
  "single-page": true,
}

This would then just render the tree under README.ciro

This will be especially important after: #37 when it will be actually feasible to have a humongous single page website even if you have images.

With this, you can split your source locally to have a faster develop time, but publish as one page.

Even more hardcore would be a publish both mode.

Auto remove newline before argument close

Investigate, but seems generally like what we want, e.g. in:

\l[
a

b
]

the first text node is a but the second text node is b\n, which is ugly.

We already have newline removal after open.

There are a few other cases where space removal would also feel nice e.g.:

\l[
aa
\l[bb]
]

maybe we would like aa to be just aa not the aa\n.

printf '\\toplevel' | ./cirodown toplevel usage leads to crash

Need to fail gracefully instead:

/home/ciro/bak/git/cirodown/index.js:1046
  for (const ast of arg) {
                    ^

TypeError: arg is not iterable
    at convert_arg (/home/ciro/bak/git/cirodown/index.js:1046:21)
    at MacroArgument.name [as convert] (/home/ciro/bak/git/cirodown/index.js:2596:14)
    at AstNode.convert (/home/ciro/bak/git/cirodown/index.js:108:44)
    at convert_arg (/home/ciro/bak/git/cirodown/index.js:1047:26)
    at MacroArgument.name [as convert] (/home/ciro/bak/git/cirodown/index.js:2596:14)
    at AstNode.convert (/home/ciro/bak/git/cirodown/index.js:108:44)
    at Object.convert (/home/ciro/bak/git/cirodown/index.js:1013:18)
    at convert_input (/home/ciro/bak/git/cirodown/cirodown:177:25)
    at Object.<anonymous> (/home/ciro/bak/git/cirodown/cirodown:400:14)
    at Module._compile (internal/modules/cjs/loader.js:689:30)

cirodown f6b6279

Indentation auto removal

Use cases:

Improve readability of nested:

\l[a]
\l[b]
\l[c
\l[d]
\l[e]
]
\l[f]

vs

\l[a]
\l[b]
\l[c
  \l[d]
  \l[e]
]
\l[f]

Downside of doing for every element: sometimes you want it, e.g.:

\C[[
    some code snippet
    that was indented on source!
]]

Markdown essentially does it only for insane lists.

Maybe we should drop this and keep it that way for insane lists only.

This is hard to implement on parsing, likely has to go into tokenizer, which makes things harder.

Tokenizer cannot distinguish element types easily. So if we do only for certain types, then it would be hard to have a version that works on sane element type as well.

One thing we could do is to compress multiple whitespaces on parse or step to a single whitespace when it does not alter the output! We kind of already do something similar with remove_whitespace_children.

The proposed documentation for this used to be:

\h[4][Argument automatic indentation removal]

Inside of a non-literal block, the very first non-whitespace character determines the indentation level of the content.

This allows seamlessly indenting complex nested content to make it more readable.

For example, a list with complex content could be written without indentation as:
``
\l[a]
\l[
b

\C[[
And now some code
]]

And a paragraph.
]
\l[c]
``
but it would be more readable as the equivalent:
``
\l[a]
\l[
  b

  \c[[
  And now some code
  ]]

  And a paragraph.
]
\l[c]
``

If a something tries to reduce the current indentation level, then that leads to an error:
``
\l[a]
\l[
  b

I'm bad because I have negative indentation.

  Back to good.
]
\l[c]
``

Proposed tests were:

// Indentation auto-removal.
// https://github.com/************/cirodown/issues/25
assert_convert_ast('indentation auto-removal simple',
  `\\C[
  aa
  bb
]
`,
  [
    a('C', [t('aa\nbb\n')]),
  ]
);
assert_convert_ast('indentation auto-removal literal',
  `\\C[[
  aa
  bb
]]
`,
  [
    a('C', [t('aa\nbb\n')]),
  ]
);
assert_convert_ast('indentation auto-removal named',
  `\c[aa]{id=
  bb
  cc
}
`,
  [
    a('C', [t('aa\nbb\n')], {id: 'bb\ncc\n'}),
  ]
);
assert_convert_ast('indentation auto-removal with paragraph',
  `\\l[
  aa

  bb
]
`,
  [
    a('ul', [
      a('l', [
        a('p', [t('aa')]),
        a('p', [t('bb\n')]),
      ]),
    ]),
  ]
);
assert_convert_ast('indentation auto-removal nested',
  `\\l[
  aa
  \\l[
    bb
  ]
]
`,
  [
    a('ul', [
      a('l', [
        t('aa\n'),
        a('ul', [
          a('l', [
            t('bb\n'),
          ]),
        ]),
      ]),
    ]),
  ]
);
assert_error('indentation auto-removal negative',
  `\\C[
  aa
bb
]
`, 3, 1);

Blow up on four or more consecutive newlines

printf 'a\n\n\n\nb' | ./cirodown

outcome:

/home/ciro/bak/git/cirodown/index.js:1818
  if (macro.properties.phrasing) {
            ^

TypeError: Cannot read property 'properties' of undefined
    at parse_add_paragraph (/home/ciro/bak/git/cirodown/index.js:1818:13)
    at parse (/home/ciro/bak/git/cirodown/index.js:1776:13)
    at Object.convert (/home/ciro/bak/git/cirodown/index.js:991:13)
    at convert_input (/home/ciro/bak/git/cirodown/cirodown:183:25)
    at Object.<anonymous> (/home/ciro/bak/git/cirodown/cirodown:432:14)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)

cirodown 52551fa

Test: https://github.com/************/cirodown/blob/996d3d65925c0aa000e45714573f168c6024617f/test.js#L205

Paragraph on hover ID buttons to left not showing up on live editor/absolute positioning generating a toplevel scrollbar on header hover

Almost fully working prototype at: https://github.com/************/cirodown/tree/flex-hoverlinks

https://************.com/cirodown/editor

cirodown cedbac7

Also image is too indented right.

Edit: if we remove the it starts showing (rendered output has to be direct child of class=cirodown element, but it shows to the left of the editor.

position: absolute from cirodown.css is not playing well with the parent flex set in the editor output.

Related:

Maybe we should just get rid of position: absolute, and instead make the link span take up space, and remove left margin.

When doing this, also make the entire height of the margin into a link to the current element. Maybe hightlight that instead of the element itself when currently selected #.

Create a proper AstArgument class

Currently we just use raw arrays, but that is potentialy bad.

The first use case has been: suppose we have an empty argument [] but want to report an error on it.

Normally we just use arg[0].line, but in this case that is not possible.

Code block filename

A common pattern that I use on Stack Overflow is:

file1.c

```
lala
lolo
```

file2.c

```
abc
def
```

Maybe we can have a \C{file=file1.c} option to formalize this usage pattern. One question the is where the code listing Code 123. would appear relative to it.

cirodown 4411040

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.