Skip to content

Commit

Permalink
Merge pull request #166 from srid/pandoc-ast
Browse files Browse the repository at this point in the history
MMark -> Pandoc AST
  • Loading branch information
srid authored May 13, 2020
2 parents e8c4286 + a5fb2a8 commit f75aa3e
Show file tree
Hide file tree
Showing 118 changed files with 2,002 additions and 678 deletions.
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

0 comments on commit f75aa3e

Please sign in to comment.