Skip to content

Commit ff79a8d

Browse files
committed
Add binary for linux
1 parent 22cafcc commit ff79a8d

File tree

6 files changed

+22
-11
lines changed

6 files changed

+22
-11
lines changed

Readme.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@ Neorg Haskell Parser aims to be a complete implementation of the [Neorg markup s
44

55
## Installation
66

7+
### Using a precompiled binary
8+
9+
I have added a compiled binary for linux in the `release` folder, which should work on most x86 linux systems.
10+
11+
### Building from Source
12+
713
You will need ghc and cabal. Then you can build the project with:
814
```bash
915
cabal build neorg-pandoc
10-
```
16+
```
1117

1218
You can run the tests with:
1319
```bash
@@ -16,14 +22,14 @@ cabal run test
1622

1723
## Usage
1824

19-
After having built `neorg-pandoc`, you can use it to transform Neorg files into Pandoc json documents. `neorg-pandoc` expects exactly one parameter, which should be the file path to the Neorg file. If parsing was successful, the json document is printed to stdout.
25+
After having aquired a binary of `neorg-pandoc`, you can use it to transform Neorg files into Pandoc json documents. `neorg-pandoc` expects exactly one parameter, which should be the file path to the Neorg file. If parsing was successful, the json document is printed to stdout.
2026

2127
An example usage might be:
2228
```bash
23-
cabal exec neorg-pandoc -- testing/test.norg | pandoc -f json -o testing/out.pdf
29+
./neorg-pandoc-linux86 testing/test.norg | pandoc -f json -o testing/out.pdf
2430
```
2531

26-
Here, I have used the `exec` command of `cabal` to execute `neorg-pandoc` and pass it the filepath of my Neorg file. The result is then piped into pandoc to create a pdf.
32+
Here, I have used the `neorg-pandoc-linux86` binary to transform my `norg` file into the pandoc `json` format. The result is piped into pandoc to create a pdf. The `-f json` argument tells pandoc that the input is a `json` file and `-o testing/out.pdf` is the location of the `pdf` file. It is also possible to transform your `norg` file into other formats; for example to markdown by replacing `-o testing/out.pdf` with `-o testing/out.md`. For further options refer to the `pandoc` documentation.
2733

2834
## Implementation status
2935

generate_binary.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
cabal build -O2
2+
cp dist-newstyle/build/x86_64-linux/ghc-8.10.7/neorg-0.1.0.0/x/neorg-pandoc/build/neorg-pandoc/neorg-pandoc release/neorg-pandoc-linux86 &&
3+
strip release/neorg-pandoc-linux86 &&
4+
upx release/neorg-pandoc-linux86

neorg.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ library
5353

5454
-- LANGUAGE extensions used by modules in this package.
5555
-- other-extensions:
56-
build-depends: base ^>=4.14.2.0, text, vector, containers, bytestring, megaparsec, time, transformers, optics-core, optics-th
56+
build-depends: base ^>=4.14.2.0, text, vector, containers, megaparsec, time, transformers, optics-core, optics-th
5757
hs-source-dirs: src
5858

5959
executable neorg-pandoc

release/neorg-pandoc-linux86

2.95 MB
Binary file not shown.

src/Neorg.hs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
module Neorg where
22

33
import Neorg.Document
4+
import Neorg.Document.Tag
5+
import Neorg.Parser
46

5-
import qualified Data.Text.IO as T
6-
import Data.Either
7-
8-
import qualified Data.ByteString.Lazy as B
9-
import Text.Megaparsec (parse, errorBundlePretty)
107
--
118
--
129
-- test :: IO ()

src/Neorg/Parser.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{-# LANGUAGE DeriveFunctor #-}
33
{-# LANGUAGE TemplateHaskell #-}
44

5+
56
module Neorg.Parser where
67

78
import Control.Applicative
@@ -14,7 +15,7 @@ import Data.Char (isLetter)
1415
import Data.Foldable (foldl')
1516
import Data.Functor
1617
import Data.Functor.Identity
17-
import Data.Maybe (catMaybes)
18+
import Data.Maybe ( catMaybes )
1819
import qualified Data.Set as S
1920
import Data.Text (Text, pack, unpack)
2021
import qualified Data.Text as T
@@ -44,6 +45,7 @@ data InlineState = InlineState {_modifierInline :: ModifierInline, _delimitedAct
4445

4546
data ModifierInline = NoModifier Inline | OpenModifier String Inline ModifierInline deriving (Show)
4647

48+
hasModifier :: String -> ModifierInline -> Bool
4749
hasModifier c (NoModifier _) = False
4850
hasModifier c1 (OpenModifier c2 i b) = c1 == c2 || hasModifier c1 b
4951

@@ -55,8 +57,10 @@ makeLenses ''InlineState
5557

5658
makeLenses ''ModifierInline
5759

60+
initialInlineState :: InlineState
5861
initialInlineState = InlineState (NoModifier (ConcatInline V.empty)) False
5962

63+
defaultParserState :: ParserState
6064
defaultParserState = ParserState I0 emptyDocumentMeta
6165

6266
parse :: GenerateTagParser tags => Text -> Text -> Either Text (Document tags)

0 commit comments

Comments
 (0)