Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MMark -> Pandoc AST #166

Merged
merged 46 commits into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
f5d18fd
Add pandoc and commonmark dependency
srid May 8, 2020
18c92c9
Prototype: commonmark parse to Pandoc AST
srid May 9, 2020
e7ff587
Fix build
srid May 9, 2020
07d021c
Merge branch 'master' into pandoc-ast
srid May 9, 2020
64000c8
WIP: use Pandoc instead of MMark
srid May 9, 2020
8ed1a68
Parse YAML
srid May 9, 2020
76fd1dd
WIP: Start rewriting query evaluator
srid May 9, 2020
7458a5c
Begin building pandoc AST for query results
srid May 9, 2020
f1ace0d
Walk block and inlines separately
srid May 9, 2020
a9c6e99
Render tag tree in AST
srid May 9, 2020
3964c2d
Finish rendering, except fontawesome doesn't work with pandoc
srid May 9, 2020
d4399e9
Fix fontawesome icons
srid May 10, 2020
c41df6d
Enable commonmark exts for GFM
srid May 10, 2020
c75ef65
Add more Markdown extensions
srid May 10, 2020
43d0a10
Add cabal.project
srid May 10, 2020
14c1221
Resurrect OpenGraph first paragraph text
srid May 10, 2020
88efb5f
Make parseMarkdown not partial
srid May 10, 2020
a084ae8
Refactor
srid May 10, 2020
e20f89a
Move Query modules to library
srid May 10, 2020
12709eb
Remove MMark code
srid May 11, 2020
910e4e5
Fix tests
srid May 11, 2020
2972a5e
Up ver to 0.5
srid May 11, 2020
d773fbd
Update docs
srid May 11, 2020
f545984
Change font style a bit, for 0.5
srid May 11, 2020
aa16e43
Fix date font in listings
srid May 11, 2020
f3379cb
ChangeLog and cleanups
srid May 11, 2020
5e4b871
Switch to GHC 8.6, and use reflex-dom
srid May 11, 2020
2073492
Switch to using reflex-platform for Nix
srid May 11, 2020
9d80d4f
Update CI action to run correct nix build
srid May 12, 2020
711fe59
Update ghcid scripts
srid May 12, 2020
12d8496
Render zettel pandoc using reflex-dom-pandoc
srid May 12, 2020
ef1d516
Add nix CI configuration
srid May 12, 2020
352e8cd
Disable github CI
srid May 12, 2020
0cda3bd
Attempt to enable separate bin output (failed)
srid May 12, 2020
98119e4
Obviate the -A argument in nix commands
srid May 12, 2020
fe09900
Relicense under AGPL
srid May 12, 2020
a2b1460
Fix skylighting override
srid May 12, 2020
dcafe59
Finish the bulk of reflex-dom-pandoc
srid May 13, 2020
49d2e5a
Drop the whole git based revisioning
srid May 13, 2020
15fe600
Add attributes extension
srid May 13, 2020
4c13718
Footnotes
srid May 13, 2020
38dbdbe
guide: make use of footnotes
srid May 13, 2020
bd9c060
reflex-dom-pandoc HACK instructions
srid May 13, 2020
d8b7892
Update installation docs
srid May 13, 2020
67300dd
Merge pull request #172 from srid/reflex-dom
srid May 13, 2020
a5fb2a8
Final cleanups
srid May 13, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .dir-locals.el

This file was deleted.

20 changes: 0 additions & 20 deletions .github/workflows/continuous-integration.yaml

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ result
.shake

guide/.neuron

neuron.prof
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change Log for neuron

## 0.5.0.0 (UNRELEASED)

- Markdown: switch to Pandoc, and commonmark. #166
- Markdown parsing is consequently less strict and more permissive
- With this change, neuron can potentially support other text formats (org,
reST, etc.)
- Switch to GHC 8.6 (for reflex-dom)

## 0.4.0.0

- Notable changes
Expand Down
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ Contributions are highly appreciated. Please note the following guidelines:
## Autoformatting

I autoformat every Haskell source using [ormolu](https://github.com/tweag/ormolu). Before opening a PR you are encouraged to do the same. However if you have trouble installing ormolu for whatever reason, don't let that prevent you from contributing.

## Test your build

Run `nix-build` with your changes to make sure that everything compiles, and the tests succeed.
690 changes: 661 additions & 29 deletions LICENSE

Large diffs are not rendered by default.

30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# neuron

[![BSD3](https://img.shields.io/badge/License-BSD-blue.svg)](https://en.wikipedia.org/wiki/BSD_License)
[![AGPL](https://img.shields.io/badge/License-AGPL%20v3-blue.svg)](https://en.wikipedia.org/wiki/Affero_General_Public_License)
[![built with nix](https://img.shields.io/badge/Built_With-Nix-5277C3.svg?logo=nixos&labelColor=73C3D5)](https://builtwithnix.org)
[![Zulip chat](https://img.shields.io/badge/zulip-join_chat-brightgreen.svg)](https://funprog.zulipchat.com/#narrow/stream/231929-Neuron)

Expand All @@ -21,7 +21,7 @@ See [neuron.zettel.page](https://neuron.zettel.page/) for the full guide to inst

## Developing

When modifying `src/Neuron`, use ghcid as instructed as follows to monitor compile errors:
When modifying `src`, use ghcid as instructed as follows to monitor compile errors:

```bash
nix-shell --run ghcid
Expand All @@ -42,3 +42,29 @@ Unit tests can be run via ghcid as follows:
```
bin/test
```

### Developing on reflex-dom-pandoc

Neuron delegates HTML rendering of the Pandoc AST to [reflex-dom-pandoc](https://github.com/srid/reflex-dom-pandoc). To hack on it, first [install Obelisk](https://github.com/obsidiansystems/obelisk#installing-obelisk) and then:

```sh
# This will clone the git repo of reflex-dom-pandoc at dep/reflex-dom-pandoc
ob thunk unpack dep/reflex-dom-pandoc

# Let's work on that repo
cd dep/reflex-dom-pandoc

# Run ghcid (using neuron's nix config)
nix-shell ../../shell.nix --run ghcid
```

Now as you edit the reflex-dom-pandoc sources, ghcid should give you compiler feedback. Once you are done with your changes, simply re-run neuron's ghcid or bin/run (see further above) and it should reflect your changes.

When you are done, commit your changes to reflex-dom-pandoc (presumably in a branch) and then `git push` it. Finally, you must "pack" the thunk and commit the changes to the neuron repo:

```sh
cd ../.. # Back to neuron
rm -rf dep/reflex-platform/dist-newstyle # cleanup build artifacts before packing
ob thunk pack dep/reflex-dom-pandoc
git add dep/reflex-dom-pandoc
```
1 change: 1 addition & 0 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages: neuron.cabal
86 changes: 1 addition & 85 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,85 +1 @@
let
# To upgrade rib, go to https://github.com/srid/rib/commits/master, select the
# revision you would like to upgrade to and set it here. Consult rib's
# ChangeLog.md to check any notes on API migration.
ribRevision = "b38ee96";
# We are using the same nixpkgs rev used by rib. Ideally this should be done
# automatically.
nixpkgsRev = "05f0934825c2";
projectRoot = ./.;
in {
# Rib library source to use
rib ? builtins.fetchTarball "https://github.com/srid/rib/archive/${ribRevision}.tar.gz"
# Cabal project root
, root ? ""
# Cabal project name
, name ? "neuron"
, gitRev ? ""
, source-overrides ? {}
, pkgs ? import (builtins.fetchTarball "https://github.com/nixos/nixpkgs/archive/${nixpkgsRev}.tar.gz") {}
, ...
}:

let
inherit (import (builtins.fetchTarball "https://github.com/hercules-ci/gitignore/archive/7415c4f.tar.gz") { inherit (pkgs) lib; })
gitignoreSource;
neuronSearchScript = pkgs.runCommand "neuron-search" { buildInputs = [ pkgs.makeWrapper ]; } ''
mkdir -p $out/bin
makeWrapper ${./.}/src-bash/neuron-search $out/bin/neuron-search --prefix 'PATH' ':' \
"${pkgs.fzf}/bin:${pkgs.ripgrep}/bin:${pkgs.gawk}/bin:${pkgs.bat}/bin:${pkgs.findutils}/bin:${pkgs.envsubst}/bin"'';
additional-packages = pkgs:
[ neuronSearchScript
];
excludeContent = path: typ:
let d = baseNameOf (toString path);
in !(d == "guide" && typ == "directory");
neuronSrc = gitignoreSource projectRoot;
gitDescribe = pkgs.runCommand "neuron-gitDescribe"
{ buildInputs = [ pkgs.git ]; }
''
mkdir $out
git -C ${projectRoot} describe --long --always --dirty | tr -d '\n' > $out/output
'';
neuronRev = if gitRev == "" then builtins.readFile (gitDescribe + /output) else gitRev;
# Overwrite src/Neuron/Version.hs as git won't be available in the Nix derivation.
neuronRoot = pkgs.runCommand "neuron" { buildInputs = [ neuronSrc ]; }
''
mkdir $out
cp -r -p ${neuronSrc}/* $out/
chmod -R u+w $out/
cat << EOF > $out/src/app/Neuron/Version/RepoVersion.hs
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Neuron.Version.RepoVersion (version) where
import Relude
version :: Maybe Text
version = Just "${neuronRev}"
EOF
'';
sources = {
dsum = builtins.fetchTarball "https://github.com/obsidiansystems/dependent-sum/archive/73ab6cb.tar.gz";
# https://github.com/obsidiansystems/aeson-gadt-th/pull/22
aeson-gadt-th = builtins.fetchTarball "https://github.com/srid/aeson-gadt-th/archive/ece1007.tar.gz";
};

in import rib {
inherit name additional-packages;
root = if root == "" then neuronRoot else root;
source-overrides = {
neuron = neuronRoot;
# Until https://github.com/obsidiansystems/which/pull/6 is merged
which = builtins.fetchTarball "https://github.com/srid/which/archive/5061a97.tar.gz";
dependent-sum = sources.dsum + "/dependent-sum";
dependent-sum-template = sources.dsum + "/dependent-sum-template";
aeson-gadt-th = sources.aeson-gadt-th;
} // source-overrides;
overrides = self: super: with pkgs.haskell.lib; {
# We must add neuron-search as a runtime dependency to the 'neuron'
# Haskell package so that other apps `import`ing this defafult.nix would
# know where to find when building the neuron library dependency through
# cabal (instead of directly via nix).
neuron = super.neuron.overrideDerivation (drv: {
propagatedBuildInputs = drv.propagatedBuildInputs ++ [neuronSearchScript];
});
};
}
(import ./project.nix {}).ghc.neuron
2 changes: 2 additions & 0 deletions dep/HsYAML/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# DO NOT HAND-EDIT THIS FILE
import (import ./thunk.nix)
8 changes: 8 additions & 0 deletions dep/HsYAML/github.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"owner": "haskell-hvr",
"repo": "HsYAML",
"branch": "0.2",
"private": false,
"rev": "cb98cb15cf40cbb7504c6e2d2faa80cbbe4673bc",
"sha256": "048cryn3zwb2kc6ryyk2vq8q37ls3x454zvspvz62b3n2c1rsm19"
}
9 changes: 9 additions & 0 deletions dep/HsYAML/thunk.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# DO NOT HAND-EDIT THIS FILE
let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }:
if !fetchSubmodules && !private then builtins.fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256;
} else (import <nixpkgs> {}).fetchFromGitHub {
inherit owner repo rev sha256 fetchSubmodules private;
};
json = builtins.fromJSON (builtins.readFile ./github.json);
in fetch json
1 change: 1 addition & 0 deletions dep/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
These dependencies are to be managed by the `ob thunk` command from obelisk, and not hand-edited.
2 changes: 2 additions & 0 deletions dep/alga/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# DO NOT HAND-EDIT THIS FILE
import (import ./thunk.nix)
8 changes: 8 additions & 0 deletions dep/alga/github.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"owner": "snowleopard",
"repo": "alga",
"branch": "heads/v0.5",
"private": false,
"rev": "408849340506b856a63bcb2ef7d912940ccb3bd7",
"sha256": "11rqzn88snrj22jifvxls7qjjvhsv13idlc4nzbkv7nqmgdcpsyq"
}
9 changes: 9 additions & 0 deletions dep/alga/thunk.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# DO NOT HAND-EDIT THIS FILE
let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }:
if !fetchSubmodules && !private then builtins.fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256;
} else (import <nixpkgs> {}).fetchFromGitHub {
inherit owner repo rev sha256 fetchSubmodules private;
};
json = builtins.fromJSON (builtins.readFile ./github.json);
in fetch json
2 changes: 2 additions & 0 deletions dep/clay/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# DO NOT HAND-EDIT THIS FILE
import (import ./thunk.nix)
8 changes: 8 additions & 0 deletions dep/clay/github.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"owner": "sebastiaanvisser",
"repo": "clay",
"branch": "master",
"private": false,
"rev": "dcc4fc6d8b55af4814bd3f9bbb6d32e2fa2751a8",
"sha256": "1dm71z1q7yaq0kl2yb0vr0lsbd8byq5qkdb2kvr26jq48nfq2xdc"
}
9 changes: 9 additions & 0 deletions dep/clay/thunk.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# DO NOT HAND-EDIT THIS FILE
let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }:
if !fetchSubmodules && !private then builtins.fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256;
} else (import <nixpkgs> {}).fetchFromGitHub {
inherit owner repo rev sha256 fetchSubmodules private;
};
json = builtins.fromJSON (builtins.readFile ./github.json);
in fetch json
2 changes: 2 additions & 0 deletions dep/commonmark-hs/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# DO NOT HAND-EDIT THIS FILE
import (import ./thunk.nix)
8 changes: 8 additions & 0 deletions dep/commonmark-hs/github.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"owner": "jgm",
"repo": "commonmark-hs",
"branch": "master",
"private": false,
"rev": "c9afe7c1ca25dbc1f0580187bb422bd1681ae1b5",
"sha256": "0dhj554jfa5m4s4dfbwnbrkxfnk22b7bgrsjdl5fijw3m6lslfyk"
}
9 changes: 9 additions & 0 deletions dep/commonmark-hs/thunk.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# DO NOT HAND-EDIT THIS FILE
let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }:
if !fetchSubmodules && !private then builtins.fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256;
} else (import <nixpkgs> {}).fetchFromGitHub {
inherit owner repo rev sha256 fetchSubmodules private;
};
json = builtins.fromJSON (builtins.readFile ./github.json);
in fetch json
2 changes: 2 additions & 0 deletions dep/doclayout/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# DO NOT HAND-EDIT THIS FILE
import (import ./thunk.nix)
8 changes: 8 additions & 0 deletions dep/doclayout/github.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"owner": "jgm",
"repo": "doclayout",
"branch": "master",
"private": false,
"rev": "7454b04674b647e3e4fc3977a13dad9db365f55e",
"sha256": "01c16gq31wbf9y4jrzs52ggf680nwz65f9j0818n8pkk671xsjxv"
}
9 changes: 9 additions & 0 deletions dep/doclayout/thunk.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# DO NOT HAND-EDIT THIS FILE
let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }:
if !fetchSubmodules && !private then builtins.fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256;
} else (import <nixpkgs> {}).fetchFromGitHub {
inherit owner repo rev sha256 fetchSubmodules private;
};
json = builtins.fromJSON (builtins.readFile ./github.json);
in fetch json
2 changes: 2 additions & 0 deletions dep/doctemplates/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# DO NOT HAND-EDIT THIS FILE
import (import ./thunk.nix)
8 changes: 8 additions & 0 deletions dep/doctemplates/github.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"owner": "jgm",
"repo": "doctemplates",
"branch": "master",
"private": false,
"rev": "f116210025fd8af48b864b875dfe880a722be737",
"sha256": "07k6211d3i9firmnf4j7s9ipyk9k6fxncbqiw11dqf2zll6ngcck"
}
9 changes: 9 additions & 0 deletions dep/doctemplates/thunk.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# DO NOT HAND-EDIT THIS FILE
let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }:
if !fetchSubmodules && !private then builtins.fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256;
} else (import <nixpkgs> {}).fetchFromGitHub {
inherit owner repo rev sha256 fetchSubmodules private;
};
json = builtins.fromJSON (builtins.readFile ./github.json);
in fetch json
2 changes: 2 additions & 0 deletions dep/emojis/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# DO NOT HAND-EDIT THIS FILE
import (import ./thunk.nix)
8 changes: 8 additions & 0 deletions dep/emojis/github.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"owner": "jgm",
"repo": "emojis",
"branch": "master",
"private": false,
"rev": "74bcd7b19fb572ac920e691c7587665f0c175710",
"sha256": "0jl6xvfnchkxkwrkrlxzgwn39srscgarpdk3iplr2lwmcz2xr81w"
}
9 changes: 9 additions & 0 deletions dep/emojis/thunk.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# DO NOT HAND-EDIT THIS FILE
let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }:
if !fetchSubmodules && !private then builtins.fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256;
} else (import <nixpkgs> {}).fetchFromGitHub {
inherit owner repo rev sha256 fetchSubmodules private;
};
json = builtins.fromJSON (builtins.readFile ./github.json);
in fetch json
2 changes: 2 additions & 0 deletions dep/hslua/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# DO NOT HAND-EDIT THIS FILE
import (import ./thunk.nix)
8 changes: 8 additions & 0 deletions dep/hslua/github.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"owner": "hslua",
"repo": "hslua",
"branch": "master",
"private": false,
"rev": "b72a6e5efec158327a4c33e8c5dafaf8b424b222",
"sha256": "0g19f7j2983kknp77xagldfikbis779cn9d9k2f39slrnnfqhwqh"
}
9 changes: 9 additions & 0 deletions dep/hslua/thunk.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# DO NOT HAND-EDIT THIS FILE
let fetch = { private ? false, fetchSubmodules ? false, owner, repo, rev, sha256, ... }:
if !fetchSubmodules && !private then builtins.fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz"; inherit sha256;
} else (import <nixpkgs> {}).fetchFromGitHub {
inherit owner repo rev sha256 fetchSubmodules private;
};
json = builtins.fromJSON (builtins.readFile ./github.json);
in fetch json
2 changes: 2 additions & 0 deletions dep/jira-wiki-markup/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# DO NOT HAND-EDIT THIS FILE
import (import ./thunk.nix)
8 changes: 8 additions & 0 deletions dep/jira-wiki-markup/github.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"owner": "tarleb",
"repo": "jira-wiki-markup",
"branch": "master",
"private": false,
"rev": "cab6c8e058a4f0966bfa0679f65ef806ef1055f3",
"sha256": "1hq048ffd07a7jir66455682473rhza6lv8jl0g0fxlld1dh30r4"
}
Loading