Compare commits
44 Commits
v0.1.1
...
d0dc737c79
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d0dc737c79 | ||
|
|
1c9877015d | ||
|
|
2938d5809a | ||
|
|
f7ec89858d | ||
|
|
67b4dfdce6 | ||
|
|
63d092c83d | ||
|
|
a7b298eeec | ||
|
|
1bbfbc3164 | ||
|
|
2bcc3f0599 | ||
|
|
b93a12c32c | ||
|
|
df3045e424 | ||
|
|
72b8fec1be | ||
|
|
ab17904b1c | ||
|
|
306878c95d | ||
|
|
5768c8acda | ||
|
|
e28290ed79 | ||
|
|
fbabf60559 | ||
|
|
92abac37e2 | ||
|
|
899073e54f | ||
|
|
eb379af78d | ||
|
|
422804d846 | ||
|
|
cc83431d62 | ||
|
|
00354ccc20 | ||
|
|
b75eed6b1e | ||
|
|
e33ec4a02c | ||
|
|
f7afcec824 | ||
|
|
cf0991fdff | ||
|
|
d1e0ee831c | ||
|
|
34985c9045 | ||
|
|
7da09fea74 | ||
|
|
fc28e3b514 | ||
|
|
df5ee5af16 | ||
|
|
012c192aed | ||
|
|
67ca0fe8dd | ||
|
|
290a700a22 | ||
|
|
729be9302b | ||
|
|
44ad6753ca | ||
|
|
cd1b4ba785 | ||
|
|
1f10d3d064 | ||
|
|
f6e539a40b | ||
|
|
3ee18072c2 | ||
|
|
77de97703f | ||
|
|
023dd05267 | ||
|
|
66c71e7e40 |
260
.lighthouse/pipeline-rust-build.yaml
Normal file
260
.lighthouse/pipeline-rust-build.yaml
Normal file
@@ -0,0 +1,260 @@
|
|||||||
|
apiVersion: tekton.dev/v1beta1
|
||||||
|
kind: PipelineRun
|
||||||
|
metadata:
|
||||||
|
name: rust-build
|
||||||
|
spec:
|
||||||
|
pipelineSpec:
|
||||||
|
params:
|
||||||
|
- name: image-name
|
||||||
|
description: The name for the built image
|
||||||
|
type: string
|
||||||
|
- name: path-to-image-context
|
||||||
|
description: The path to the build context
|
||||||
|
type: string
|
||||||
|
- name: path-to-dockerfile
|
||||||
|
description: The path to the Dockerfile
|
||||||
|
type: string
|
||||||
|
- name: command
|
||||||
|
type: array
|
||||||
|
description: Command to run.
|
||||||
|
default: []
|
||||||
|
tasks:
|
||||||
|
- name: report-pending
|
||||||
|
taskRef:
|
||||||
|
name: gitea-set-status
|
||||||
|
runAfter:
|
||||||
|
- fetch-repository
|
||||||
|
params:
|
||||||
|
- name: CONTEXT
|
||||||
|
value: "$(params.JOB_NAME)"
|
||||||
|
- name: REPO_FULL_NAME
|
||||||
|
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
||||||
|
- name: GITEA_HOST_URL
|
||||||
|
value: code.fizz.buzz
|
||||||
|
- name: SHA
|
||||||
|
value: "$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: DESCRIPTION
|
||||||
|
value: "Build $(params.JOB_NAME) has started"
|
||||||
|
- name: STATE
|
||||||
|
value: pending
|
||||||
|
- name: TARGET_URL
|
||||||
|
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
||||||
|
- name: fetch-repository
|
||||||
|
taskRef:
|
||||||
|
name: git-clone
|
||||||
|
workspaces:
|
||||||
|
- name: output
|
||||||
|
workspace: git-source
|
||||||
|
params:
|
||||||
|
- name: url
|
||||||
|
value: $(params.REPO_URL)
|
||||||
|
- name: revision
|
||||||
|
value: $(params.PULL_BASE_SHA)
|
||||||
|
- name: deleteExisting
|
||||||
|
value: "true"
|
||||||
|
- name: build-image
|
||||||
|
taskRef:
|
||||||
|
name: kaniko
|
||||||
|
params:
|
||||||
|
- name: IMAGE
|
||||||
|
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: CONTEXT
|
||||||
|
value: $(params.path-to-image-context)
|
||||||
|
- name: DOCKERFILE
|
||||||
|
value: $(params.path-to-dockerfile)
|
||||||
|
- name: BUILDER_IMAGE
|
||||||
|
value: "gcr.io/kaniko-project/executor:v1.12.1"
|
||||||
|
- name: EXTRA_ARGS
|
||||||
|
value:
|
||||||
|
- --cache=true
|
||||||
|
- --cache-copy-layers
|
||||||
|
- --cache-repo=harbor.fizz.buzz/kanikocache/cache
|
||||||
|
- --use-new-run # Should result in a speed-up
|
||||||
|
- --reproducible # To remove timestamps so layer caching works.
|
||||||
|
- --snapshot-mode=redo
|
||||||
|
- --skip-unused-stages=true
|
||||||
|
- --registry-mirror=dockerhub.dockerhub.svc.cluster.local
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: dockerconfig
|
||||||
|
workspace: docker-credentials
|
||||||
|
runAfter:
|
||||||
|
- fetch-repository
|
||||||
|
- name: run-image-none
|
||||||
|
taskRef:
|
||||||
|
name: run-docker-image
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: cargo-cache
|
||||||
|
workspace: cargo-cache
|
||||||
|
runAfter:
|
||||||
|
- build-image
|
||||||
|
params:
|
||||||
|
- name: command
|
||||||
|
value: ["$(params.command[*])"]
|
||||||
|
- name: args
|
||||||
|
value: ["--no-default-features"]
|
||||||
|
- name: docker-image
|
||||||
|
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: run-image-tracing
|
||||||
|
taskRef:
|
||||||
|
name: run-docker-image
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: cargo-cache
|
||||||
|
workspace: cargo-cache
|
||||||
|
runAfter:
|
||||||
|
- run-image-none
|
||||||
|
params:
|
||||||
|
- name: command
|
||||||
|
value: ["$(params.command[*])"]
|
||||||
|
- name: args
|
||||||
|
value: ["--no-default-features", "--features", "tracing"]
|
||||||
|
- name: docker-image
|
||||||
|
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: run-image-compare
|
||||||
|
taskRef:
|
||||||
|
name: run-docker-image
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: cargo-cache
|
||||||
|
workspace: cargo-cache
|
||||||
|
runAfter:
|
||||||
|
- run-image-tracing
|
||||||
|
params:
|
||||||
|
- name: command
|
||||||
|
value: ["$(params.command[*])"]
|
||||||
|
- name: args
|
||||||
|
value: ["--no-default-features", "--features", "compare"]
|
||||||
|
- name: docker-image
|
||||||
|
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: run-image-default
|
||||||
|
taskRef:
|
||||||
|
name: run-docker-image
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: cargo-cache
|
||||||
|
workspace: cargo-cache
|
||||||
|
runAfter:
|
||||||
|
- run-image-compare
|
||||||
|
params:
|
||||||
|
- name: command
|
||||||
|
value: ["$(params.command[*])"]
|
||||||
|
- name: args
|
||||||
|
value: []
|
||||||
|
- name: docker-image
|
||||||
|
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: run-image-all
|
||||||
|
taskRef:
|
||||||
|
name: run-docker-image
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: cargo-cache
|
||||||
|
workspace: cargo-cache
|
||||||
|
runAfter:
|
||||||
|
- run-image-default
|
||||||
|
params:
|
||||||
|
- name: command
|
||||||
|
value: ["$(params.command[*])"]
|
||||||
|
- name: args
|
||||||
|
value: ["--no-default-features", "--features", "tracing,compare"]
|
||||||
|
- name: docker-image
|
||||||
|
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
||||||
|
finally:
|
||||||
|
- name: report-success
|
||||||
|
when:
|
||||||
|
- input: "$(tasks.status)"
|
||||||
|
operator: in
|
||||||
|
values: ["Succeeded", "Completed"]
|
||||||
|
taskRef:
|
||||||
|
name: gitea-set-status
|
||||||
|
params:
|
||||||
|
- name: CONTEXT
|
||||||
|
value: "$(params.JOB_NAME)"
|
||||||
|
- name: REPO_FULL_NAME
|
||||||
|
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
||||||
|
- name: GITEA_HOST_URL
|
||||||
|
value: code.fizz.buzz
|
||||||
|
- name: SHA
|
||||||
|
value: "$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: DESCRIPTION
|
||||||
|
value: "Build $(params.JOB_NAME) has succeeded"
|
||||||
|
- name: STATE
|
||||||
|
value: success
|
||||||
|
- name: TARGET_URL
|
||||||
|
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
||||||
|
- name: report-failure
|
||||||
|
when:
|
||||||
|
- input: "$(tasks.status)"
|
||||||
|
operator: in
|
||||||
|
values: ["Failed"]
|
||||||
|
taskRef:
|
||||||
|
name: gitea-set-status
|
||||||
|
params:
|
||||||
|
- name: CONTEXT
|
||||||
|
value: "$(params.JOB_NAME)"
|
||||||
|
- name: REPO_FULL_NAME
|
||||||
|
value: "$(params.REPO_OWNER)/$(params.REPO_NAME)"
|
||||||
|
- name: GITEA_HOST_URL
|
||||||
|
value: code.fizz.buzz
|
||||||
|
- name: SHA
|
||||||
|
value: "$(tasks.fetch-repository.results.commit)"
|
||||||
|
- name: DESCRIPTION
|
||||||
|
value: "Build $(params.JOB_NAME) has failed"
|
||||||
|
- name: STATE
|
||||||
|
value: failure
|
||||||
|
- name: TARGET_URL
|
||||||
|
value: "https://tekton.fizz.buzz/#/namespaces/$(context.pipelineRun.namespace)/pipelineruns/$(context.pipelineRun.name)"
|
||||||
|
- name: cargo-cache-autoclean
|
||||||
|
taskRef:
|
||||||
|
name: run-docker-image
|
||||||
|
workspaces:
|
||||||
|
- name: source
|
||||||
|
workspace: git-source
|
||||||
|
- name: cargo-cache
|
||||||
|
workspace: cargo-cache
|
||||||
|
params:
|
||||||
|
- name: command
|
||||||
|
value: [cargo, cache, --autoclean]
|
||||||
|
- name: args
|
||||||
|
value: []
|
||||||
|
- name: docker-image
|
||||||
|
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
||||||
|
workspaces:
|
||||||
|
- name: git-source
|
||||||
|
- name: docker-credentials
|
||||||
|
- name: cargo-cache
|
||||||
|
workspaces:
|
||||||
|
- name: git-source
|
||||||
|
volumeClaimTemplate:
|
||||||
|
spec:
|
||||||
|
storageClassName: "nfs-client"
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 10Gi
|
||||||
|
subPath: rust-source
|
||||||
|
- name: cargo-cache
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: organic-cargo-cache-build
|
||||||
|
- name: docker-credentials
|
||||||
|
secret:
|
||||||
|
secretName: harbor-plain
|
||||||
|
serviceAccountName: build-bot
|
||||||
|
timeout: 240h0m0s
|
||||||
|
params:
|
||||||
|
- name: image-name
|
||||||
|
value: "harbor.fizz.buzz/private/organic-build"
|
||||||
|
- name: path-to-image-context
|
||||||
|
value: docker/organic_build/
|
||||||
|
- name: path-to-dockerfile
|
||||||
|
value: docker/organic_build/Dockerfile
|
||||||
|
- name: command
|
||||||
|
value: [cargo, build]
|
||||||
@@ -4,6 +4,10 @@ metadata:
|
|||||||
name: rust-test
|
name: rust-test
|
||||||
spec:
|
spec:
|
||||||
pipelineSpec:
|
pipelineSpec:
|
||||||
|
timeouts:
|
||||||
|
pipeline: "2h0m0s"
|
||||||
|
tasks: "1h0m40s"
|
||||||
|
finally: "0h30m0s"
|
||||||
params:
|
params:
|
||||||
- name: image-name
|
- name: image-name
|
||||||
description: The name for the built image
|
description: The name for the built image
|
||||||
@@ -201,7 +205,6 @@ spec:
|
|||||||
secret:
|
secret:
|
||||||
secretName: harbor-plain
|
secretName: harbor-plain
|
||||||
serviceAccountName: build-bot
|
serviceAccountName: build-bot
|
||||||
timeout: 240h0m0s
|
|
||||||
params:
|
params:
|
||||||
- name: image-name
|
- name: image-name
|
||||||
value: "harbor.fizz.buzz/private/organic-test"
|
value: "harbor.fizz.buzz/private/organic-test"
|
||||||
|
|||||||
@@ -16,3 +16,10 @@ spec:
|
|||||||
skip_branches:
|
skip_branches:
|
||||||
# We already run on every commit, so running when the semver tags get pushed is causing needless double-processing.
|
# We already run on every commit, so running when the semver tags get pushed is causing needless double-processing.
|
||||||
- "^v[0-9]+\\.[0-9]+\\.[0-9]+$"
|
- "^v[0-9]+\\.[0-9]+\\.[0-9]+$"
|
||||||
|
- name: rust-build
|
||||||
|
source: "pipeline-rust-build.yaml"
|
||||||
|
# Override https-based url from lighthouse events.
|
||||||
|
clone_uri: "git@code.fizz.buzz:talexander/organic.git"
|
||||||
|
skip_branches:
|
||||||
|
# We already run on every commit, so running when the semver tags get pushed is causing needless double-processing.
|
||||||
|
- "^v[0-9]+\\.[0-9]+\\.[0-9]+$"
|
||||||
|
|||||||
29
Cargo.toml
29
Cargo.toml
@@ -1,37 +1,48 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "organic"
|
name = "organic"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
authors = ["Tom Alexander <tom@fizz.buzz>"]
|
authors = ["Tom Alexander <tom@fizz.buzz>"]
|
||||||
description = "An org-mode parser."
|
description = "An org-mode parser."
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "0BSD"
|
license = "0BSD"
|
||||||
repository = "https://code.fizz.buzz/talexander/organic"
|
repository = "https://code.fizz.buzz/talexander/organic"
|
||||||
readme = "README.org"
|
readme = "README.md"
|
||||||
keywords = ["emacs", "org-mode"]
|
keywords = ["emacs", "org-mode"]
|
||||||
categories = ["parsing"]
|
categories = ["parsing"]
|
||||||
|
resolver = "2"
|
||||||
|
include = [
|
||||||
|
"LICENSE",
|
||||||
|
"**/*.rs",
|
||||||
|
"Cargo.toml",
|
||||||
|
"tests/*"
|
||||||
|
]
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "organic"
|
name = "organic"
|
||||||
path = "src/lib.rs"
|
path = "src/lib.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "toy"
|
# This bin exists for development purposes only. The real target of this crate is the library.
|
||||||
|
name = "compare"
|
||||||
path = "src/main.rs"
|
path = "src/main.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nom = "7.1.1"
|
nom = "7.1.1"
|
||||||
opentelemetry = "0.17.0"
|
opentelemetry = { version = "0.20.0", optional = true, default-features = false, features = ["trace", "rt-tokio"] }
|
||||||
opentelemetry-jaeger = "0.16.0"
|
opentelemetry-otlp = { version = "0.13.0", optional = true }
|
||||||
tracing = "0.1.37"
|
opentelemetry-semantic-conventions = { version = "0.12.0", optional = true }
|
||||||
tracing-opentelemetry = "0.17.2"
|
tokio = { version = "1.30.0", optional = true, default-features = false, features = ["rt", "rt-multi-thread"] }
|
||||||
tracing-subscriber = {version="0.3.16", features=["env-filter"]}
|
tracing = { version = "0.1.37", optional = true }
|
||||||
|
tracing-opentelemetry = { version = "0.20.0", optional = true }
|
||||||
|
tracing-subscriber = { version = "0.3.17", optional = true, features = ["env-filter"] }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
walkdir = "2.3.3"
|
walkdir = "2.3.3"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["compare"]
|
default = ["compare", "tracing"]
|
||||||
compare = []
|
compare = []
|
||||||
|
tracing = ["dep:opentelemetry", "dep:opentelemetry-otlp", "dep:opentelemetry-semantic-conventions", "dep:tokio", "dep:tracing", "dep:tracing-opentelemetry", "dep:tracing-subscriber"]
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
lto = true
|
lto = true
|
||||||
|
|||||||
27
Makefile
27
Makefile
@@ -35,7 +35,17 @@ clean:
|
|||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test:
|
test:
|
||||||
> cargo test --lib --test test_loader -- --test-threads $(TESTJOBS)
|
> cargo test --no-fail-fast --lib --test test_loader -- --test-threads $(TESTJOBS)
|
||||||
|
|
||||||
|
.PHONY: dockertest
|
||||||
|
dockertest:
|
||||||
|
> $(MAKE) -C docker/organic_test
|
||||||
|
> docker run --rm -i -t -v "$$(readlink -f ./):/source:ro" --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target -w /source organic-test cargo test --no-fail-fast --lib --test test_loader -- --test-threads $(TESTJOBS)
|
||||||
|
|
||||||
|
.PHONY: dockerclean
|
||||||
|
dockerclean:
|
||||||
|
# Delete volumes created for running the tests in docker. This does not touch anything related to the jaeger docker container.
|
||||||
|
> docker volume rm cargo-cache rust-cache
|
||||||
|
|
||||||
.PHONY: integrationtest
|
.PHONY: integrationtest
|
||||||
integrationtest:
|
integrationtest:
|
||||||
@@ -45,17 +55,12 @@ integrationtest:
|
|||||||
unittest:
|
unittest:
|
||||||
> cargo test --lib -- --test-threads $(TESTJOBS)
|
> cargo test --lib -- --test-threads $(TESTJOBS)
|
||||||
|
|
||||||
.PHONY: run
|
|
||||||
run:
|
|
||||||
> cargo run
|
|
||||||
|
|
||||||
.PHONY: debug
|
|
||||||
debug:
|
|
||||||
> RUST_LOG=debug cargo run
|
|
||||||
|
|
||||||
.PHONY: jaeger
|
.PHONY: jaeger
|
||||||
jaeger:
|
jaeger:
|
||||||
> docker run -d --rm --name toylanguagedocker -p 6831:6831/udp -p 6832:6832/udp -p 16686:16686 -p 14268:14268 jaegertracing/all-in-one:latest
|
# 4317 for OTLP gRPC, 4318 for OTLP HTTP. We currently use gRPC but I forward both ports regardless.
|
||||||
|
#
|
||||||
|
# These flags didn't help even though they seem like they would: --collector.queue-size=20000 --collector.num-workers=100
|
||||||
|
> docker run -d --rm --name organicdocker -p 4317:4317 -p 4318:4318 -p 16686:16686 -e COLLECTOR_OTLP_ENABLED=true jaegertracing/all-in-one:1.47 --collector.grpc-server.max-message-size=20000000 --collector.otlp.grpc.max-message-size=20000000
|
||||||
|
|
||||||
.PHONY: jaegerweb
|
.PHONY: jaegerweb
|
||||||
jaegerweb:
|
jaegerweb:
|
||||||
@@ -63,4 +68,4 @@ jaegerweb:
|
|||||||
|
|
||||||
.PHONY: jaegerstop
|
.PHONY: jaegerstop
|
||||||
jaegerstop:
|
jaegerstop:
|
||||||
> docker stop toylanguagedocker
|
> docker stop organicdocker
|
||||||
|
|||||||
13
README.md
Normal file
13
README.md
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# Organic - Free Range Org-Mode
|
||||||
|
|
||||||
|
Organic is an emacs-less implementation of an [org-mode](https://orgmode.org/) parser.
|
||||||
|
|
||||||
|
|
||||||
|
## Project Status
|
||||||
|
|
||||||
|
This project is a personal learning project to grow my experience in [rust](https://www.rust-lang.org/). It is under development and at this time I would not recommend anyone use this code. The goal is to turn this into a project others can use, at which point more information will appear in this README.
|
||||||
|
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
This project is released under the public-domain-equivalent [0BSD license](https://www.tldrlegal.com/license/bsd-0-clause-license). This license puts no restrictions on the use of this code (you do not even have to include the copyright notice or license text when using it). HOWEVER, this project has a couple permissively licensed dependencies which do require their copyright notices and/or license texts to be included. I am not a lawyer and this is not legal advice but it is my layperson's understanding that if you distribute a binary with this library linked in, you will need to abide by their terms since their code will also be linked in your binary. I try to keep the dependencies to a minimum and the most restrictive dependency I will ever include is a permissively licensed one.
|
||||||
10
README.org
10
README.org
@@ -1,10 +0,0 @@
|
|||||||
#+options: toc:nil
|
|
||||||
#+title: Organic - Free Range Org-Mode
|
|
||||||
|
|
||||||
Organic is an emacs-less implementation of an [[https://orgmode.org/][org-mode]] parser.
|
|
||||||
|
|
||||||
* Project Status
|
|
||||||
This project is a personal learning project to grow my experience in [[https://www.rust-lang.org/][rust]]. It is under development and at this time I would not recommend anyone use this code. The goal is to turn this into a project others can use, at which point more information will appear in this README.
|
|
||||||
|
|
||||||
* License
|
|
||||||
This project is released under the public-domain-equivalent [[https://www.tldrlegal.com/license/bsd-0-clause-license][0BSD license]]. This license puts no restrictions on the use of this code (you do not even have to include the copyright notice or license text when using it). HOWEVER, this project has a couple permissively licensed dependencies which do require their copyright notices and/or license texts to be included. I am not a lawyer and this is not legal advice but it is my layperson's understanding that if you distribute a binary with this library linked in, you will need to abide by their terms since their code will also be linked in your binary. I try to keep the dependencies to a minimum and the most restrictive dependency I will ever include is a permissively licensed one.
|
|
||||||
3
build.rs
3
build.rs
@@ -74,7 +74,8 @@ fn is_expect_fail(name: &str) -> Option<&str> {
|
|||||||
"drawer_drawer_with_headline_inside" => Some("Apparently lines with :end: become their own paragraph. This odd behavior needs to be investigated more."),
|
"drawer_drawer_with_headline_inside" => Some("Apparently lines with :end: become their own paragraph. This odd behavior needs to be investigated more."),
|
||||||
"element_container_priority_footnote_definition_dynamic_block" => Some("Apparently broken begin lines become their own paragraph."),
|
"element_container_priority_footnote_definition_dynamic_block" => Some("Apparently broken begin lines become their own paragraph."),
|
||||||
"paragraphs_paragraph_with_backslash_line_breaks" => Some("The text we're getting out of the parse tree is already processed to remove line breaks, so our comparison needs to take that into account."),
|
"paragraphs_paragraph_with_backslash_line_breaks" => Some("The text we're getting out of the parse tree is already processed to remove line breaks, so our comparison needs to take that into account."),
|
||||||
"export_snippet_paragraph_break_precedent" => Some("Emacs 28 has broken behavior so the tests in the CI fail."),
|
"export_snippet_paragraph_break_precedence" => Some("The latest code for org-mode is matching the export snippet without the closing @@."), // https://list.orgmode.org/orgmode/fb61ea28-f004-4c25-adf7-69fc55683ed4@app.fastmail.com/T/#u
|
||||||
|
"plain_lists_trailing_whitespace_ownership" => Some("My plain list implementation is currently broken."),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
4
docker/organic_build/Dockerfile
Normal file
4
docker/organic_build/Dockerfile
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
FROM rustlang/rust:nightly-alpine3.17
|
||||||
|
|
||||||
|
RUN apk add --no-cache musl-dev
|
||||||
|
RUN cargo install --locked --no-default-features --features ci-autoclean cargo-cache
|
||||||
35
docker/organic_build/Makefile
Normal file
35
docker/organic_build/Makefile
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
IMAGE_NAME:=organic-build
|
||||||
|
# REMOTE_REPO:=harbor.fizz.buzz/private
|
||||||
|
|
||||||
|
.PHONY: all
|
||||||
|
all: build push
|
||||||
|
|
||||||
|
.PHONY: build
|
||||||
|
build:
|
||||||
|
docker build -t $(IMAGE_NAME) -f Dockerfile ../
|
||||||
|
|
||||||
|
.PHONY: push
|
||||||
|
push:
|
||||||
|
ifdef REMOTE_REPO
|
||||||
|
docker tag $(IMAGE_NAME) $(REMOTE_REPO)/$(IMAGE_NAME)
|
||||||
|
docker push $(REMOTE_REPO)/$(IMAGE_NAME)
|
||||||
|
else
|
||||||
|
@echo "REMOTE_REPO not defined, not pushing to a remote repo."
|
||||||
|
endif
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
docker rmi $(IMAGE_NAME)
|
||||||
|
ifdef REMOTE_REPO
|
||||||
|
docker rmi $(REMOTE_REPO)/$(IMAGE_NAME)
|
||||||
|
else
|
||||||
|
@echo "REMOTE_REPO not defined, not removing from remote repo."
|
||||||
|
endif
|
||||||
|
|
||||||
|
.PHONY: run
|
||||||
|
run:
|
||||||
|
docker run --rm -i -t $(IMAGE_NAME)
|
||||||
|
|
||||||
|
.PHONY: shell
|
||||||
|
shell:
|
||||||
|
docker run --rm -i -t --entrypoint /bin/bash $(IMAGE_NAME)
|
||||||
@@ -1,4 +1,30 @@
|
|||||||
FROM rustlang/rust:nightly-alpine3.17
|
FROM alpine:3.17 AS build
|
||||||
|
|
||||||
RUN apk add --no-cache musl-dev emacs
|
RUN apk add --no-cache build-base musl-dev git autoconf make texinfo gnutls-dev ncurses-dev gawk
|
||||||
|
|
||||||
|
|
||||||
|
FROM build AS build-emacs
|
||||||
|
|
||||||
|
RUN git clone --depth 1 --branch emacs-29.1 https://git.savannah.gnu.org/git/emacs.git /root/emacs
|
||||||
|
WORKDIR /root/emacs
|
||||||
|
RUN mkdir /root/dist
|
||||||
|
RUN ./autogen.sh
|
||||||
|
RUN ./configure --prefix /usr --without-x --without-sound
|
||||||
|
RUN make
|
||||||
|
RUN make DESTDIR="/root/dist" install
|
||||||
|
|
||||||
|
|
||||||
|
FROM build AS build-org-mode
|
||||||
|
COPY --from=build-emacs /root/dist/ /
|
||||||
|
RUN mkdir /root/dist
|
||||||
|
RUN mkdir /root/org-mode && git -C /root/org-mode init && git -C /root/org-mode remote add origin https://git.savannah.gnu.org/git/emacs/org-mode.git && git -C /root/org-mode fetch origin b89bc55867d7cb809c379d371d12d409db785154 && git -C /root/org-mode checkout FETCH_HEAD
|
||||||
|
WORKDIR /root/org-mode
|
||||||
|
RUN make compile
|
||||||
|
RUN make DESTDIR="/root/dist" install
|
||||||
|
|
||||||
|
|
||||||
|
FROM rustlang/rust:nightly-alpine3.17
|
||||||
|
RUN apk add --no-cache musl-dev ncurses gnutls
|
||||||
RUN cargo install --locked --no-default-features --features ci-autoclean cargo-cache
|
RUN cargo install --locked --no-default-features --features ci-autoclean cargo-cache
|
||||||
|
COPY --from=build-emacs /root/dist/ /
|
||||||
|
COPY --from=build-org-mode /root/dist/ /
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
Headings add exit matcher for heading
|
|
||||||
|
|
||||||
Paragraphs add exit matcher for elements (but it should be sans paragraph)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
* foo
|
|
||||||
* bar
|
|
||||||
* baz
|
|
||||||
|
|
||||||
context tree -> ()
|
|
||||||
|
|
||||||
match * foo
|
|
||||||
|
|
||||||
context tree -> exit(heading matcher)
|
|
||||||
|
|
||||||
check exit
|
|
||||||
invoke heading matcher
|
|
||||||
check exit
|
|
||||||
invoke heading matcher
|
|
||||||
check exit
|
|
||||||
invoke heading matcher
|
|
||||||
adds second heading matcher exit
|
|
||||||
|
|
||||||
|
|
||||||
Ways around this:
|
|
||||||
- Always parse SOMETHING before checking for exit
|
|
||||||
- Doesn't always seem possible
|
|
||||||
- Disable exit matchers during exit check
|
|
||||||
- Seems like it would break syntax
|
|
||||||
- Have separate parsers for the beginning of the exit condition (for example, checking for just the headline instead of the full heading parser)
|
|
||||||
- Won't be possible with paragraphs ending at any other element
|
|
||||||
- Check exit matchers in parent parser
|
|
||||||
- Will this work? seems like it would just create larger loops
|
|
||||||
27
notes/optimization_ideas.org
Normal file
27
notes/optimization_ideas.org
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
* Analysis
|
||||||
|
** Parse start per character
|
||||||
|
It might help analysis to record how often we start a specific type of parse for each character. For example, at the start of a plain list, if we had a count of how often each character was the start of a parse of a list we could use that to see how often that list is getting re-parsed.
|
||||||
|
* Optimizations
|
||||||
|
** Edit whitespace for list items
|
||||||
|
Whether or not a list item owns the trailing whitespace depends on if it is the last list item in that list. Since we do not know ahead of time if an item is the last item in the list, we have to either re-parse the list item or modify it after parsing.
|
||||||
|
|
||||||
|
*** For
|
||||||
|
We already are modifying the source of some elements after-the-fact with src_rust{set_source()} so this would be more of the same.
|
||||||
|
*** Against
|
||||||
|
I'd like to phase out such modifications because they seem hacky and fragile.
|
||||||
|
** Make detect element function
|
||||||
|
Some exit matchers are based on when the next element is found. Some elements do not need to be fully parsed to identify that they are a valid element. For example, src_org{1. foo} can already be identified as the start of a plain list (in the right context) without needing to parse the entire element.
|
||||||
|
*** For
|
||||||
|
Avoiding parsing the entire element for an exit matcher would reduce redundant parses.
|
||||||
|
*** Against
|
||||||
|
This adds code complexity and introduces the potential for bugs.
|
||||||
|
|
||||||
|
How many elements can be reasonably early-detected? For example, src_org{#+begin_src foo} is not enough to detect the start of a source block because without the src_org{#+end_src} it is just plain text.
|
||||||
|
** Grab multiple characters in plaintext parser before checking exit matcher
|
||||||
|
Currently we check the exit matcher after each character inside the plain text parser (and many others). Are there character sequences we can assume no exit matcher will trigger between? For example, a contiguous string of latin-alphabet letters?
|
||||||
|
*** For
|
||||||
|
This could significantly reduce our calls to exit matchers.
|
||||||
|
*** Against
|
||||||
|
I think targets would break this.
|
||||||
|
|
||||||
|
The exit matchers are already implicitly building this behavior since they should all exit very early when the starting character is wrong. Putting this logic in a centralized place, far away from where those characters are actually going to be used, is unfortunate for readability.
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
1. foo
|
||||||
|
|
||||||
|
1. bar
|
||||||
|
|
||||||
|
2. baz
|
||||||
|
|
||||||
|
2. lorem
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ipsum
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
foo bar.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
* Lorem
|
||||||
|
baz
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
* Ipsum
|
||||||
|
alpha
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
beta
|
||||||
56
scripts/run_docker_compare.bash
Executable file
56
scripts/run_docker_compare.bash
Executable file
@@ -0,0 +1,56 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: ${SHELL:="NO"} # or YES to launch a shell instead of running the test
|
||||||
|
: ${TRACE:="NO"} # or YES to send traces to jaeger
|
||||||
|
: ${BACKTRACE:="NO"} # or YES to print a rust backtrace when panicking
|
||||||
|
|
||||||
|
cd "$DIR/../"
|
||||||
|
REALPATH=$(command -v uu-realpath || command -v realpath)
|
||||||
|
MAKE=$(command -v gmake || command -v make)
|
||||||
|
|
||||||
|
function main {
|
||||||
|
local org_file="$($REALPATH "$1")"
|
||||||
|
build_container
|
||||||
|
launch_container "$org_file"
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_container {
|
||||||
|
$MAKE -C "$DIR/../docker/organic_test"
|
||||||
|
}
|
||||||
|
|
||||||
|
function launch_container {
|
||||||
|
local org_file="$1"
|
||||||
|
local additional_flags=()
|
||||||
|
local additional_args=()
|
||||||
|
|
||||||
|
local init_script=$(cat <<EOF
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=\$'\n\t'
|
||||||
|
|
||||||
|
cargo run -- /input.org
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
|
if [ "$SHELL" != "YES" ]; then
|
||||||
|
additional_args+=(sh -c "$init_script")
|
||||||
|
else
|
||||||
|
additional_flags+=(-i -t)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$TRACE" = "YES" ]; then
|
||||||
|
# We use the host network so it can talk to jaeger hosted at 127.0.0.1
|
||||||
|
additional_flags+=(--network=host --env RUST_LOG=debug)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$BACKTRACE" = "YES" ]; then
|
||||||
|
additional_flags+=(--env RUST_BACKTRACE=full)
|
||||||
|
fi
|
||||||
|
|
||||||
|
docker run "${additional_flags[@]}" --rm -v "${org_file}:/input.org:ro" -v "$($REALPATH ./):/source:ro" --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target -w /source organic-test "${additional_args[@]}"
|
||||||
|
}
|
||||||
|
|
||||||
|
main "${@}"
|
||||||
57
scripts/run_docker_integration_test.bash
Executable file
57
scripts/run_docker_integration_test.bash
Executable file
@@ -0,0 +1,57 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
cd "$DIR/../"
|
||||||
|
REALPATH=$(command -v uu-realpath || command -v realpath)
|
||||||
|
MAKE=$(command -v gmake || command -v make)
|
||||||
|
|
||||||
|
function main {
|
||||||
|
local test_names=$(get_test_names "${@}")
|
||||||
|
build_container
|
||||||
|
|
||||||
|
local test
|
||||||
|
while read test; do
|
||||||
|
launch_container "$test"
|
||||||
|
done<<<"$test_names"
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_container {
|
||||||
|
$MAKE -C "$DIR/../docker/organic_test"
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_test_names {
|
||||||
|
local test_file
|
||||||
|
local samples_dir=$($REALPATH "$DIR/../org_mode_samples")
|
||||||
|
for test_file in "$@"
|
||||||
|
do
|
||||||
|
if [ -e "$test_file" ]; then
|
||||||
|
local test_file_full_path=$($REALPATH "$test_file")
|
||||||
|
local relative_to_samples=$($REALPATH --relative-to "$samples_dir" "$test_file_full_path")
|
||||||
|
local without_extension="${relative_to_samples%.org}"
|
||||||
|
echo "${without_extension/\//_}" | tr '[:upper:]' '[:lower:]'
|
||||||
|
else
|
||||||
|
echo "$test_file" | tr '[:upper:]' '[:lower:]'
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
function launch_container {
|
||||||
|
local test="$1"
|
||||||
|
local additional_args=()
|
||||||
|
|
||||||
|
local init_script=$(cat <<EOF
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=\$'\n\t'
|
||||||
|
|
||||||
|
cargo test --no-fail-fast --lib --test test_loader "$test" -- --show-output
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
|
docker run --rm -v "$($REALPATH ./):/source:ro" --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target -w /source organic-test sh -c "$init_script"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
main "${@}"
|
||||||
@@ -4,17 +4,27 @@ set -euo pipefail
|
|||||||
IFS=$'\n\t'
|
IFS=$'\n\t'
|
||||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
cd "$DIR/../"
|
||||||
REALPATH=$(command -v uu-realpath || command -v realpath)
|
REALPATH=$(command -v uu-realpath || command -v realpath)
|
||||||
|
|
||||||
samples_dir=$(readlink -f "$DIR/../org_mode_samples")
|
function main {
|
||||||
|
local test_names=$(get_test_names "${@}")
|
||||||
|
|
||||||
|
local test
|
||||||
|
while read test; do
|
||||||
|
cargo test --no-fail-fast --test test_loader "$test" -- --show-output
|
||||||
|
done<<<"$test_names"
|
||||||
|
}
|
||||||
|
|
||||||
function get_test_names {
|
function get_test_names {
|
||||||
|
local test_file
|
||||||
|
local samples_dir=$($REALPATH "$DIR/../org_mode_samples")
|
||||||
for test_file in "$@"
|
for test_file in "$@"
|
||||||
do
|
do
|
||||||
if [ -e "$test_file" ]; then
|
if [ -e "$test_file" ]; then
|
||||||
test_file_full_path=$(readlink -f "$test_file")
|
local test_file_full_path=$($REALPATH "$test_file")
|
||||||
relative_to_samples=$($REALPATH --relative-to "$samples_dir" "$test_file_full_path")
|
local relative_to_samples=$($REALPATH --relative-to "$samples_dir" "$test_file_full_path")
|
||||||
without_extension="${relative_to_samples%.org}"
|
local without_extension="${relative_to_samples%.org}"
|
||||||
echo "${without_extension/\//_}" | tr '[:upper:]' '[:lower:]'
|
echo "${without_extension/\//_}" | tr '[:upper:]' '[:lower:]'
|
||||||
else
|
else
|
||||||
echo "$test_file" | tr '[:upper:]' '[:lower:]'
|
echo "$test_file" | tr '[:upper:]' '[:lower:]'
|
||||||
@@ -22,6 +32,4 @@ function get_test_names {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
get_test_names "$@" | while read test; do
|
main "${@}"
|
||||||
(cd "$DIR/../" && cargo test --no-fail-fast --test test_loader "$test" -- --show-output)
|
|
||||||
done
|
|
||||||
|
|||||||
@@ -48,6 +48,21 @@ pub fn assert_bounds<'s, S: Source<'s>>(
|
|||||||
.nth(1)
|
.nth(1)
|
||||||
.ok_or("Should have an attributes child.")?;
|
.ok_or("Should have an attributes child.")?;
|
||||||
let attributes_map = attributes_child.as_map()?;
|
let attributes_map = attributes_child.as_map()?;
|
||||||
|
let standard_properties = attributes_map.get(":standard-properties");
|
||||||
|
let (begin, end) = if standard_properties.is_some() {
|
||||||
|
let std_props = standard_properties
|
||||||
|
.expect("if statement proves its Some")
|
||||||
|
.as_vector()?;
|
||||||
|
let begin = std_props
|
||||||
|
.get(0)
|
||||||
|
.ok_or("Missing first element in standard properties")?
|
||||||
|
.as_atom()?;
|
||||||
|
let end = std_props
|
||||||
|
.get(1)
|
||||||
|
.ok_or("Missing first element in standard properties")?
|
||||||
|
.as_atom()?;
|
||||||
|
(begin, end)
|
||||||
|
} else {
|
||||||
let begin = attributes_map
|
let begin = attributes_map
|
||||||
.get(":begin")
|
.get(":begin")
|
||||||
.ok_or("Missing :begin attribute.")?
|
.ok_or("Missing :begin attribute.")?
|
||||||
@@ -56,6 +71,8 @@ pub fn assert_bounds<'s, S: Source<'s>>(
|
|||||||
.get(":end")
|
.get(":end")
|
||||||
.ok_or("Missing :end attribute.")?
|
.ok_or("Missing :end attribute.")?
|
||||||
.as_atom()?;
|
.as_atom()?;
|
||||||
|
(begin, end)
|
||||||
|
};
|
||||||
let (rust_begin, rust_end) = get_offsets(source, rust);
|
let (rust_begin, rust_end) = get_offsets(source, rust);
|
||||||
if (rust_begin + 1).to_string() != begin || (rust_end + 1).to_string() != end {
|
if (rust_begin + 1).to_string() != begin || (rust_end + 1).to_string() != end {
|
||||||
Err(format!("Rust bounds ({rust_begin}, {rust_end}) do not match emacs bounds ({emacs_begin}, {emacs_end})", rust_begin = rust_begin + 1, rust_end = rust_end + 1, emacs_begin=begin, emacs_end=end))?;
|
Err(format!("Rust bounds ({rust_begin}, {rust_end}) do not match emacs bounds ({emacs_begin}, {emacs_end})", rust_begin = rust_begin + 1, rust_end = rust_end + 1, emacs_begin=begin, emacs_end=end))?;
|
||||||
|
|||||||
@@ -1,34 +1,71 @@
|
|||||||
use tracing_subscriber::layer::SubscriberExt;
|
#[cfg(feature = "tracing")]
|
||||||
|
use opentelemetry_otlp::WithExportConfig;
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
|
use tracing_subscriber::prelude::__tracing_subscriber_SubscriberExt;
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
use tracing_subscriber::util::SubscriberInitExt;
|
use tracing_subscriber::util::SubscriberInitExt;
|
||||||
// use tracing_subscriber::EnvFilter;
|
|
||||||
|
|
||||||
|
const SERVICE_NAME: &'static str = "organic";
|
||||||
|
|
||||||
|
// Despite the obvious verbosity that fully-qualifying everything causes, in these functions I am fully-qualifying everything relating to tracing. This is because the tracing feature involves multiple libraries working together and so I think it is beneficial to see which libraries contribute which bits.
|
||||||
|
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
pub fn init_telemetry() -> Result<(), Box<dyn std::error::Error>> {
|
pub fn init_telemetry() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
// let env_filter = EnvFilter::try_from_default_env().unwrap_or(EnvFilter::new("warn"));
|
// by default it will hit http://localhost:4317 with a gRPC payload
|
||||||
|
// TODO: I think the endpoint can be controlled by the OTEL_EXPORTER_OTLP_TRACES_ENDPOINT env variable instead of hard-coded into this code base. Regardless, I am the only developer right now so I am not too concerned.
|
||||||
|
let exporter = opentelemetry_otlp::new_exporter()
|
||||||
|
.tonic()
|
||||||
|
// Using "localhost" is broken inside the docker container when tracing
|
||||||
|
.with_endpoint("http://127.0.0.1:4317/v1/traces");
|
||||||
|
|
||||||
// let stdout = tracing_subscriber::fmt::Layer::new()
|
let tracer = opentelemetry_otlp::new_pipeline()
|
||||||
// .pretty()
|
.tracing()
|
||||||
// .with_file(true)
|
.with_exporter(exporter)
|
||||||
// .with_line_number(true)
|
.with_trace_config(opentelemetry::sdk::trace::config().with_resource(
|
||||||
// .with_thread_ids(false)
|
opentelemetry::sdk::Resource::new(vec![opentelemetry::KeyValue::new(
|
||||||
// .with_target(false);
|
opentelemetry_semantic_conventions::resource::SERVICE_NAME,
|
||||||
|
SERVICE_NAME.to_string(),
|
||||||
|
)]),
|
||||||
|
))
|
||||||
|
// If I do install_batch then 1K+ spans will get orphaned off into their own trace and I get the error message "OpenTelemetry trace error occurred. cannot send message to batch processor as the channel is closed"
|
||||||
|
//
|
||||||
|
// If I do install_simple then it only creates 1 trace (which is good!) but my console gets spammed with this concerning log message that makes me think it might be dropping the extra spans on the floor: "OpenTelemetry trace error occurred. Exporter otlp encountered the following error(s): the grpc server returns error (Unknown error): , detailed error message: Service was not ready: transport error"
|
||||||
|
//
|
||||||
|
// I suspect it is related to this bug: https://github.com/open-telemetry/opentelemetry-rust/issues/888
|
||||||
|
//
|
||||||
|
// .install_simple()
|
||||||
|
.install_batch(opentelemetry::runtime::Tokio)
|
||||||
|
.expect("Error: Failed to initialize the tracer.");
|
||||||
|
|
||||||
opentelemetry::global::set_text_map_propagator(opentelemetry_jaeger::Propagator::new());
|
let subscriber = tracing_subscriber::Registry::default();
|
||||||
let tracer = opentelemetry_jaeger::new_pipeline()
|
let level_filter_layer = tracing_subscriber::EnvFilter::try_from_default_env()
|
||||||
.with_service_name("toy_language")
|
.unwrap_or(tracing_subscriber::EnvFilter::new("WARN"));
|
||||||
.install_simple()?;
|
let tracing_layer = tracing_opentelemetry::layer().with_tracer(tracer);
|
||||||
|
|
||||||
let opentelemetry = tracing_opentelemetry::layer().with_tracer(tracer);
|
opentelemetry::global::set_text_map_propagator(
|
||||||
|
opentelemetry::sdk::propagation::TraceContextPropagator::new(),
|
||||||
|
);
|
||||||
|
|
||||||
tracing_subscriber::registry()
|
subscriber
|
||||||
// .with(env_filter)
|
.with(level_filter_layer)
|
||||||
.with(opentelemetry)
|
.with(tracing_layer)
|
||||||
// .with(stdout)
|
|
||||||
.try_init()?;
|
.try_init()?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
pub fn shutdown_telemetry() -> Result<(), Box<dyn std::error::Error>> {
|
pub fn shutdown_telemetry() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
opentelemetry::global::shutdown_tracer_provider();
|
opentelemetry::global::shutdown_tracer_provider();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "tracing"))]
|
||||||
|
pub fn init_telemetry() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "tracing"))]
|
||||||
|
pub fn shutdown_telemetry() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|||||||
77
src/main.rs
77
src/main.rs
@@ -1,17 +1,84 @@
|
|||||||
#![feature(round_char_boundary)]
|
#![feature(round_char_boundary)]
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
|
#[cfg(feature = "compare")]
|
||||||
use ::organic::parser::document;
|
use ::organic::parser::document;
|
||||||
|
#[cfg(feature = "compare")]
|
||||||
|
use organic::compare_document;
|
||||||
|
#[cfg(feature = "compare")]
|
||||||
|
use organic::emacs_parse_org_document;
|
||||||
|
#[cfg(feature = "compare")]
|
||||||
|
use organic::parser::sexp::sexp_with_padding;
|
||||||
|
use tracing::span;
|
||||||
|
|
||||||
use crate::init_tracing::init_telemetry;
|
use crate::init_tracing::init_telemetry;
|
||||||
use crate::init_tracing::shutdown_telemetry;
|
use crate::init_tracing::shutdown_telemetry;
|
||||||
mod init_tracing;
|
mod init_tracing;
|
||||||
|
|
||||||
const TEST_DOC: &'static str = include_str!("../toy_language.txt");
|
#[cfg(not(feature = "tracing"))]
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
main_body()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let rt = tokio::runtime::Runtime::new()?;
|
||||||
|
let result = rt.block_on(async { main_body() });
|
||||||
|
result
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main_body() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
init_telemetry()?;
|
init_telemetry()?;
|
||||||
let parsed = document(TEST_DOC);
|
let compare_result = {
|
||||||
println!("{}\n\n\n", TEST_DOC);
|
#[cfg(feature = "tracing")]
|
||||||
println!("{:#?}", parsed);
|
let span = span!(tracing::Level::DEBUG, "run_compare");
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
|
let _enter = span.enter();
|
||||||
|
|
||||||
|
run_compare(
|
||||||
|
std::env::args()
|
||||||
|
.nth(1)
|
||||||
|
.expect("Pass a single file into this script."),
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
shutdown_telemetry()?;
|
shutdown_telemetry()?;
|
||||||
|
compare_result?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "compare")]
|
||||||
|
fn run_compare<P: AsRef<Path>>(todo_org_path: P) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let org_contents = std::fs::read_to_string(todo_org_path.as_ref()).expect("Read org file.");
|
||||||
|
let (remaining, rust_parsed) = document(org_contents.as_str()).expect("Org Parse failure");
|
||||||
|
let org_sexp =
|
||||||
|
emacs_parse_org_document(todo_org_path.as_ref()).expect("Use emacs to parse org file.");
|
||||||
|
let (_remaining, parsed_sexp) =
|
||||||
|
sexp_with_padding(org_sexp.as_str()).expect("Sexp Parse failure");
|
||||||
|
|
||||||
|
println!("{}\n\n\n", org_contents.as_str());
|
||||||
|
println!("{}", org_sexp);
|
||||||
|
println!("{:#?}", rust_parsed);
|
||||||
|
|
||||||
|
// We do the diffing after printing out both parsed forms in case the diffing panics
|
||||||
|
let diff_result =
|
||||||
|
compare_document(&parsed_sexp, &rust_parsed).expect("Compare parsed documents.");
|
||||||
|
diff_result
|
||||||
|
.print()
|
||||||
|
.expect("Print document parse tree diff.");
|
||||||
|
|
||||||
|
if diff_result.is_bad() {
|
||||||
|
Err("Diff results do not match.")?;
|
||||||
|
}
|
||||||
|
if remaining != "" {
|
||||||
|
Err(format!("There was unparsed text remaining: {}", remaining))?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "compare"))]
|
||||||
|
fn run_compare<P: AsRef<Path>>(_todo_org_path: P) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
println!("This program was built with compare disabled. Doing nothing.");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ use crate::parser::util::exit_matcher_parser;
|
|||||||
use crate::parser::util::get_consumed;
|
use crate::parser::util::get_consumed;
|
||||||
use crate::parser::AngleLink;
|
use crate::parser::AngleLink;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn angle_link<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, AngleLink<'s>> {
|
pub fn angle_link<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, AngleLink<'s>> {
|
||||||
let (remaining, _) = tag("<")(input)?;
|
let (remaining, _) = tag("<")(input)?;
|
||||||
let (remaining, proto) = protocol(context, remaining)?;
|
let (remaining, proto) = protocol(context, remaining)?;
|
||||||
@@ -33,7 +33,7 @@ pub fn angle_link<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s s
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn path_angle<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn path_angle<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let parser_context =
|
let parser_context =
|
||||||
context.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
|
context.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||||
@@ -47,7 +47,7 @@ fn path_angle<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str,
|
|||||||
Ok((remaining, path))
|
Ok((remaining, path))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn path_angle_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn path_angle_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
tag(">")(input)
|
tag(">")(input)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ use crate::parser::util::exit_matcher_parser;
|
|||||||
use crate::parser::util::get_consumed;
|
use crate::parser::util::get_consumed;
|
||||||
use crate::parser::Object;
|
use crate::parser::Object;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn citation<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Citation<'s>> {
|
pub fn citation<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Citation<'s>> {
|
||||||
// TODO: Despite being a standard object, citations cannot exist inside the global prefix/suffix for other citations because citations must contain something that matches @key which is forbidden inside the global prefix/suffix. This TODO is to evaluate if its worth putting in an explicit check for this (which can be easily accomplished by checking the output of `get_bracket_depth()`). I suspect its not worth it because I expect, outside of intentionally crafted inputs, this parser will exit immediately inside a citation since it is unlikely to find the "[cite" substring inside a citation global prefix/suffix.
|
// TODO: Despite being a standard object, citations cannot exist inside the global prefix/suffix for other citations because citations must contain something that matches @key which is forbidden inside the global prefix/suffix. This TODO is to evaluate if its worth putting in an explicit check for this (which can be easily accomplished by checking the output of `get_bracket_depth()`). I suspect its not worth it because I expect, outside of intentionally crafted inputs, this parser will exit immediately inside a citation since it is unlikely to find the "[cite" substring inside a citation global prefix/suffix.
|
||||||
let (remaining, _) = tag_no_case("[cite")(input)?;
|
let (remaining, _) = tag_no_case("[cite")(input)?;
|
||||||
@@ -47,7 +47,7 @@ pub fn citation<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str
|
|||||||
Ok((remaining, Citation { source }))
|
Ok((remaining, Citation { source }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn citestyle<'r, 's>(input: &'s str) -> Res<&'s str, &'s str> {
|
fn citestyle<'r, 's>(input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let (remaining, _) = tuple((tag("/"), style))(input)?;
|
let (remaining, _) = tuple((tag("/"), style))(input)?;
|
||||||
let (remaining, _) = opt(tuple((tag("/"), variant)))(remaining)?;
|
let (remaining, _) = opt(tuple((tag("/"), variant)))(remaining)?;
|
||||||
@@ -55,21 +55,21 @@ fn citestyle<'r, 's>(input: &'s str) -> Res<&'s str, &'s str> {
|
|||||||
Ok((remaining, source))
|
Ok((remaining, source))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn style<'r, 's>(input: &'s str) -> Res<&'s str, &'s str> {
|
fn style<'r, 's>(input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
recognize(many1(verify(anychar, |c| {
|
recognize(many1(verify(anychar, |c| {
|
||||||
c.is_alphanumeric() || "_-".contains(*c)
|
c.is_alphanumeric() || "_-".contains(*c)
|
||||||
})))(input)
|
})))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn variant<'r, 's>(input: &'s str) -> Res<&'s str, &'s str> {
|
fn variant<'r, 's>(input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
recognize(many1(verify(anychar, |c| {
|
recognize(many1(verify(anychar, |c| {
|
||||||
c.is_alphanumeric() || "_-/".contains(*c)
|
c.is_alphanumeric() || "_-/".contains(*c)
|
||||||
})))(input)
|
})))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn global_prefix<'r, 's>(
|
fn global_prefix<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -95,7 +95,7 @@ fn global_prefix<'r, 's>(
|
|||||||
Ok((remaining, children))
|
Ok((remaining, children))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn global_prefix_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn global_prefix_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let context_depth = get_bracket_depth(context)
|
let context_depth = get_bracket_depth(context)
|
||||||
.expect("This function should only be called from inside a citation.");
|
.expect("This function should only be called from inside a citation.");
|
||||||
@@ -127,7 +127,7 @@ fn global_prefix_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'
|
|||||||
))(input)
|
))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn global_suffix<'r, 's>(
|
fn global_suffix<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -152,7 +152,7 @@ fn global_suffix<'r, 's>(
|
|||||||
Ok((remaining, children))
|
Ok((remaining, children))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn global_suffix_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn global_suffix_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let context_depth = get_bracket_depth(context)
|
let context_depth = get_bracket_depth(context)
|
||||||
.expect("This function should only be called from inside a citation.");
|
.expect("This function should only be called from inside a citation.");
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ use crate::parser::util::get_consumed;
|
|||||||
use crate::parser::util::WORD_CONSTITUENT_CHARACTERS;
|
use crate::parser::util::WORD_CONSTITUENT_CHARACTERS;
|
||||||
use crate::parser::Object;
|
use crate::parser::Object;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn citation_reference<'r, 's>(
|
pub fn citation_reference<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -38,7 +38,7 @@ pub fn citation_reference<'r, 's>(
|
|||||||
Ok((remaining, CitationReference { source }))
|
Ok((remaining, CitationReference { source }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn citation_reference_key<'r, 's>(
|
pub fn citation_reference_key<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -58,7 +58,7 @@ pub fn citation_reference_key<'r, 's>(
|
|||||||
Ok((remaining, source))
|
Ok((remaining, source))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn key_prefix<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Vec<Object<'s>>> {
|
fn key_prefix<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Vec<Object<'s>>> {
|
||||||
// TODO: I could insert CitationBracket entries in the context after each matched object to reduce the scanning done for counting brackets which should be more efficient.
|
// TODO: I could insert CitationBracket entries in the context after each matched object to reduce the scanning done for counting brackets which should be more efficient.
|
||||||
let parser_context = context
|
let parser_context = context
|
||||||
@@ -80,7 +80,7 @@ fn key_prefix<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str,
|
|||||||
Ok((remaining, children))
|
Ok((remaining, children))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn key_suffix<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Vec<Object<'s>>> {
|
fn key_suffix<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Vec<Object<'s>>> {
|
||||||
// TODO: I could insert CitationBracket entries in the context after each matched object to reduce the scanning done for counting brackets which should be more efficient.
|
// TODO: I could insert CitationBracket entries in the context after each matched object to reduce the scanning done for counting brackets which should be more efficient.
|
||||||
let parser_context = context
|
let parser_context = context
|
||||||
@@ -102,7 +102,7 @@ fn key_suffix<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str,
|
|||||||
Ok((remaining, children))
|
Ok((remaining, children))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn get_bracket_depth<'r, 's>(context: Context<'r, 's>) -> Option<&'r CitationBracket<'s>> {
|
pub fn get_bracket_depth<'r, 's>(context: Context<'r, 's>) -> Option<&'r CitationBracket<'s>> {
|
||||||
for node in context.iter() {
|
for node in context.iter() {
|
||||||
match node.get_data() {
|
match node.get_data() {
|
||||||
@@ -113,7 +113,7 @@ pub fn get_bracket_depth<'r, 's>(context: Context<'r, 's>) -> Option<&'r Citatio
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn key_prefix_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn key_prefix_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let context_depth = get_bracket_depth(context)
|
let context_depth = get_bracket_depth(context)
|
||||||
.expect("This function should only be called from inside a citation reference.");
|
.expect("This function should only be called from inside a citation reference.");
|
||||||
@@ -145,7 +145,7 @@ fn key_prefix_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s s
|
|||||||
))(input)
|
))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn key_suffix_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn key_suffix_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let context_depth = get_bracket_depth(context)
|
let context_depth = get_bracket_depth(context)
|
||||||
.expect("This function should only be called from inside a citation reference.");
|
.expect("This function should only be called from inside a citation reference.");
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ use crate::parser::util::get_consumed;
|
|||||||
use crate::parser::util::start_of_line;
|
use crate::parser::util::start_of_line;
|
||||||
use crate::parser::Clock;
|
use crate::parser::Clock;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn clock<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Clock<'s>> {
|
pub fn clock<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Clock<'s>> {
|
||||||
start_of_line(context, input)?;
|
start_of_line(context, input)?;
|
||||||
let (remaining, _leading_whitespace) = space0(input)?;
|
let (remaining, _leading_whitespace) = space0(input)?;
|
||||||
@@ -34,7 +34,7 @@ pub fn clock<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, C
|
|||||||
Ok((remaining, Clock { source }))
|
Ok((remaining, Clock { source }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn inactive_timestamp_range_duration<'r, 's>(
|
fn inactive_timestamp_range_duration<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -56,7 +56,7 @@ fn inactive_timestamp_range_duration<'r, 's>(
|
|||||||
)))(input)
|
)))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn inactive_timestamp<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn inactive_timestamp<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
recognize(tuple((
|
recognize(tuple((
|
||||||
tag("["),
|
tag("["),
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ use crate::parser::util::immediate_in_section;
|
|||||||
use crate::parser::util::start_of_line;
|
use crate::parser::util::start_of_line;
|
||||||
use crate::parser::Comment;
|
use crate::parser::Comment;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn comment<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Comment<'s>> {
|
pub fn comment<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Comment<'s>> {
|
||||||
if immediate_in_section(context, "comment") {
|
if immediate_in_section(context, "comment") {
|
||||||
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
||||||
@@ -41,7 +41,7 @@ pub fn comment<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str,
|
|||||||
Ok((remaining, Comment { source }))
|
Ok((remaining, Comment { source }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn comment_line<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn comment_line<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
start_of_line(context, input)?;
|
start_of_line(context, input)?;
|
||||||
let (remaining, _indent) = space0(input)?;
|
let (remaining, _indent) = space0(input)?;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ use crate::parser::util::get_consumed;
|
|||||||
use crate::parser::util::start_of_line;
|
use crate::parser::util::start_of_line;
|
||||||
use crate::parser::DiarySexp;
|
use crate::parser::DiarySexp;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn diary_sexp<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, DiarySexp<'s>> {
|
pub fn diary_sexp<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, DiarySexp<'s>> {
|
||||||
start_of_line(context, input)?;
|
start_of_line(context, input)?;
|
||||||
let (remaining, _leading_whitespace) = space0(input)?;
|
let (remaining, _leading_whitespace) = space0(input)?;
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ impl<'s> Source<'s> for Heading<'s> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn document(input: &str) -> Res<&str, Document> {
|
pub fn document(input: &str) -> Res<&str, Document> {
|
||||||
let initial_context: ContextTree<'_, '_> = ContextTree::new();
|
let initial_context: ContextTree<'_, '_> = ContextTree::new();
|
||||||
@@ -122,7 +122,7 @@ pub fn document(input: &str) -> Res<&str, Document> {
|
|||||||
Ok((remaining, document))
|
Ok((remaining, document))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn _document<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Document<'s>> {
|
pub fn _document<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Document<'s>> {
|
||||||
let zeroth_section_matcher = parser_with_context!(zeroth_section)(context);
|
let zeroth_section_matcher = parser_with_context!(zeroth_section)(context);
|
||||||
let heading_matcher = parser_with_context!(heading)(context);
|
let heading_matcher = parser_with_context!(heading)(context);
|
||||||
@@ -140,7 +140,7 @@ pub fn _document<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s st
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn zeroth_section<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Section<'s>> {
|
fn zeroth_section<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Section<'s>> {
|
||||||
// TODO: The zeroth section is specialized so it probably needs its own parser
|
// TODO: The zeroth section is specialized so it probably needs its own parser
|
||||||
let parser_context = context
|
let parser_context = context
|
||||||
@@ -160,7 +160,7 @@ fn zeroth_section<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s s
|
|||||||
opt(parser_with_context!(comment)(
|
opt(parser_with_context!(comment)(
|
||||||
&without_consuming_whitespace_context,
|
&without_consuming_whitespace_context,
|
||||||
)),
|
)),
|
||||||
parser_with_context!(property_drawer)(&without_consuming_whitespace_context),
|
parser_with_context!(property_drawer)(context),
|
||||||
many0(blank_line),
|
many0(blank_line),
|
||||||
)))(input)?;
|
)))(input)?;
|
||||||
|
|
||||||
@@ -185,7 +185,7 @@ fn zeroth_section<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s s
|
|||||||
Ok((remaining, Section { source, children }))
|
Ok((remaining, Section { source, children }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn section<'r, 's>(context: Context<'r, 's>, mut input: &'s str) -> Res<&'s str, Section<'s>> {
|
fn section<'r, 's>(context: Context<'r, 's>, mut input: &'s str) -> Res<&'s str, Section<'s>> {
|
||||||
// TODO: The zeroth section is specialized so it probably needs its own parser
|
// TODO: The zeroth section is specialized so it probably needs its own parser
|
||||||
let parser_context = context
|
let parser_context = context
|
||||||
@@ -226,13 +226,13 @@ fn section<'r, 's>(context: Context<'r, 's>, mut input: &'s str) -> Res<&'s str,
|
|||||||
Ok((remaining, Section { source, children }))
|
Ok((remaining, Section { source, children }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn section_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn section_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let headline_matcher = parser_with_context!(headline)(context);
|
let headline_matcher = parser_with_context!(headline)(context);
|
||||||
recognize(headline_matcher)(input)
|
recognize(headline_matcher)(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn heading<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Heading<'s>> {
|
fn heading<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Heading<'s>> {
|
||||||
not(|i| context.check_exit_matcher(i))(input)?;
|
not(|i| context.check_exit_matcher(i))(input)?;
|
||||||
let (remaining, (star_count, _ws, title)) = headline(context, input)?;
|
let (remaining, (star_count, _ws, title)) = headline(context, input)?;
|
||||||
@@ -257,7 +257,7 @@ fn heading<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Hea
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn headline<'r, 's>(
|
fn headline<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -280,7 +280,7 @@ fn headline<'r, 's>(
|
|||||||
Ok((remaining, (star_count, ws, title)))
|
Ok((remaining, (star_count, ws, title)))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn headline_end<'r, 's>(_context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn headline_end<'r, 's>(_context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
line_ending(input)
|
line_ending(input)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ use crate::parser::Drawer;
|
|||||||
use crate::parser::Element;
|
use crate::parser::Element;
|
||||||
use crate::parser::Paragraph;
|
use crate::parser::Paragraph;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn drawer<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Drawer<'s>> {
|
pub fn drawer<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Drawer<'s>> {
|
||||||
if immediate_in_section(context, "drawer") {
|
if immediate_in_section(context, "drawer") {
|
||||||
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
||||||
@@ -88,12 +88,12 @@ pub fn drawer<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str,
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn name<'s>(input: &'s str) -> Res<&'s str, &'s str> {
|
fn name<'s>(input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
take_while(|c| WORD_CONSTITUENT_CHARACTERS.contains(c) || "-_".contains(c))(input)
|
take_while(|c| WORD_CONSTITUENT_CHARACTERS.contains(c) || "-_".contains(c))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn drawer_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn drawer_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
start_of_line(context, input)?;
|
start_of_line(context, input)?;
|
||||||
recognize(tuple((
|
recognize(tuple((
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ use crate::parser::util::immediate_in_section;
|
|||||||
use crate::parser::util::start_of_line;
|
use crate::parser::util::start_of_line;
|
||||||
use crate::parser::Element;
|
use crate::parser::Element;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn dynamic_block<'r, 's>(
|
pub fn dynamic_block<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -94,17 +94,17 @@ pub fn dynamic_block<'r, 's>(
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn name<'s>(input: &'s str) -> Res<&'s str, &'s str> {
|
fn name<'s>(input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
is_not(" \t\r\n")(input)
|
is_not(" \t\r\n")(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn parameters<'s>(input: &'s str) -> Res<&'s str, &'s str> {
|
fn parameters<'s>(input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
is_not("\r\n")(input)
|
is_not("\r\n")(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn dynamic_block_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn dynamic_block_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
start_of_line(context, input)?;
|
start_of_line(context, input)?;
|
||||||
let (remaining, source) = recognize(tuple((
|
let (remaining, source) = recognize(tuple((
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ impl<'s> Source<'s> for Element<'s> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'s> SetSource<'s> for Element<'s> {
|
impl<'s> SetSource<'s> for Element<'s> {
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn set_source(&mut self, source: &'s str) {
|
fn set_source(&mut self, source: &'s str) {
|
||||||
match self {
|
match self {
|
||||||
Element::Paragraph(obj) => obj.source = source,
|
Element::Paragraph(obj) => obj.source = source,
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ pub fn element(
|
|||||||
move |context: Context, input: &str| _element(context, input, can_be_paragraph)
|
move |context: Context, input: &str| _element(context, input, can_be_paragraph)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn _element<'r, 's>(
|
fn _element<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ use crate::parser::object::Entity;
|
|||||||
use crate::parser::parser_with_context::parser_with_context;
|
use crate::parser::parser_with_context::parser_with_context;
|
||||||
use crate::parser::util::get_consumed;
|
use crate::parser::util::get_consumed;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn entity<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Entity<'s>> {
|
pub fn entity<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Entity<'s>> {
|
||||||
let (remaining, _) = tag("\\")(input)?;
|
let (remaining, _) = tag("\\")(input)?;
|
||||||
let (remaining, entity_name) = name(context, remaining)?;
|
let (remaining, entity_name) = name(context, remaining)?;
|
||||||
@@ -33,7 +33,7 @@ pub fn entity<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str,
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn name<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn name<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
// TODO: This should be defined by org-entities and optionally org-entities-user
|
// TODO: This should be defined by org-entities and optionally org-entities-user
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ fn name<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s st
|
|||||||
Ok((remaining, proto))
|
Ok((remaining, proto))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn entity_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, ()> {
|
fn entity_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, ()> {
|
||||||
let (remaining, _) = alt((eof, recognize(satisfy(|c| !c.is_alphabetic()))))(input)?;
|
let (remaining, _) = alt((eof, recognize(satisfy(|c| !c.is_alphabetic()))))(input)?;
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
use nom::branch::alt;
|
|
||||||
use nom::bytes::complete::tag;
|
use nom::bytes::complete::tag;
|
||||||
use nom::character::complete::anychar;
|
use nom::character::complete::anychar;
|
||||||
use nom::combinator::opt;
|
use nom::combinator::opt;
|
||||||
use nom::combinator::peek;
|
|
||||||
use nom::combinator::recognize;
|
use nom::combinator::recognize;
|
||||||
use nom::combinator::verify;
|
use nom::combinator::verify;
|
||||||
use nom::multi::many1;
|
use nom::multi::many1;
|
||||||
@@ -11,20 +9,30 @@ use nom::sequence::tuple;
|
|||||||
|
|
||||||
use super::Context;
|
use super::Context;
|
||||||
use crate::error::Res;
|
use crate::error::Res;
|
||||||
|
use crate::parser::exiting::ExitClass;
|
||||||
|
use crate::parser::parser_context::ContextElement;
|
||||||
|
use crate::parser::parser_context::ExitMatcherNode;
|
||||||
use crate::parser::parser_with_context::parser_with_context;
|
use crate::parser::parser_with_context::parser_with_context;
|
||||||
use crate::parser::util::exit_matcher_parser;
|
use crate::parser::util::exit_matcher_parser;
|
||||||
use crate::parser::util::get_consumed;
|
use crate::parser::util::get_consumed;
|
||||||
use crate::parser::ExportSnippet;
|
use crate::parser::ExportSnippet;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn export_snippet<'r, 's>(
|
pub fn export_snippet<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
) -> Res<&'s str, ExportSnippet<'s>> {
|
) -> Res<&'s str, ExportSnippet<'s>> {
|
||||||
let (remaining, _) = tag("@@")(input)?;
|
let (remaining, _) = tag("@@")(input)?;
|
||||||
let (remaining, backend_name) = backend(context, remaining)?;
|
let (remaining, backend_name) = backend(context, remaining)?;
|
||||||
let (remaining, backend_contents) =
|
let parser_context =
|
||||||
opt(tuple((tag(":"), parser_with_context!(contents)(context))))(remaining)?;
|
context.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||||
|
class: ExitClass::Beta,
|
||||||
|
exit_matcher: &export_snippet_end,
|
||||||
|
}));
|
||||||
|
let (remaining, backend_contents) = opt(tuple((
|
||||||
|
tag(":"),
|
||||||
|
parser_with_context!(contents)(&parser_context),
|
||||||
|
)))(remaining)?;
|
||||||
let (remaining, _) = tag("@@")(remaining)?;
|
let (remaining, _) = tag("@@")(remaining)?;
|
||||||
let source = get_consumed(input, remaining);
|
let source = get_consumed(input, remaining);
|
||||||
Ok((
|
Ok((
|
||||||
@@ -37,7 +45,7 @@ pub fn export_snippet<'r, 's>(
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn backend<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn backend<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let (remaining, backend_name) =
|
let (remaining, backend_name) =
|
||||||
recognize(many1(verify(anychar, |c| c.is_alphanumeric() || *c == '-')))(input)?;
|
recognize(many1(verify(anychar, |c| c.is_alphanumeric() || *c == '-')))(input)?;
|
||||||
@@ -45,17 +53,16 @@ fn backend<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s
|
|||||||
Ok((remaining, backend_name))
|
Ok((remaining, backend_name))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn contents<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn contents<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let (remaining, source) = recognize(verify(
|
let (remaining, source) = recognize(verify(
|
||||||
many_till(
|
many_till(anychar, parser_with_context!(exit_matcher_parser)(context)),
|
||||||
anychar,
|
|
||||||
peek(alt((
|
|
||||||
parser_with_context!(exit_matcher_parser)(context),
|
|
||||||
tag("@@"),
|
|
||||||
))),
|
|
||||||
),
|
|
||||||
|(children, _exit_contents)| !children.is_empty(),
|
|(children, _exit_contents)| !children.is_empty(),
|
||||||
))(input)?;
|
))(input)?;
|
||||||
Ok((remaining, source))
|
Ok((remaining, source))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
|
fn export_snippet_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
|
tag("@@")(input)
|
||||||
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ use crate::parser::util::get_consumed;
|
|||||||
use crate::parser::util::start_of_line;
|
use crate::parser::util::start_of_line;
|
||||||
use crate::parser::FixedWidthArea;
|
use crate::parser::FixedWidthArea;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn fixed_width_area<'r, 's>(
|
pub fn fixed_width_area<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -34,7 +34,7 @@ pub fn fixed_width_area<'r, 's>(
|
|||||||
Ok((remaining, FixedWidthArea { source }))
|
Ok((remaining, FixedWidthArea { source }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn fixed_width_area_line<'r, 's>(
|
fn fixed_width_area_line<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ use crate::parser::util::immediate_in_section;
|
|||||||
use crate::parser::util::maybe_consume_trailing_whitespace;
|
use crate::parser::util::maybe_consume_trailing_whitespace;
|
||||||
use crate::parser::util::start_of_line;
|
use crate::parser::util::start_of_line;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn footnote_definition<'r, 's>(
|
pub fn footnote_definition<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -66,7 +66,7 @@ pub fn footnote_definition<'r, 's>(
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn label<'s>(input: &'s str) -> Res<&'s str, &'s str> {
|
pub fn label<'s>(input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
alt((
|
alt((
|
||||||
digit1,
|
digit1,
|
||||||
@@ -74,7 +74,7 @@ pub fn label<'s>(input: &'s str) -> Res<&'s str, &'s str> {
|
|||||||
))(input)
|
))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn footnote_definition_end<'r, 's>(
|
fn footnote_definition_end<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ use crate::parser::util::get_consumed;
|
|||||||
use crate::parser::FootnoteReference;
|
use crate::parser::FootnoteReference;
|
||||||
use crate::parser::Object;
|
use crate::parser::Object;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn footnote_reference<'r, 's>(
|
pub fn footnote_reference<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -33,7 +33,7 @@ pub fn footnote_reference<'r, 's>(
|
|||||||
))(input)
|
))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn anonymous_footnote<'r, 's>(
|
fn anonymous_footnote<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -72,7 +72,7 @@ fn anonymous_footnote<'r, 's>(
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn inline_footnote<'r, 's>(
|
fn inline_footnote<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -113,7 +113,7 @@ fn inline_footnote<'r, 's>(
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn footnote_reference_only<'r, 's>(
|
fn footnote_reference_only<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -133,12 +133,12 @@ fn footnote_reference_only<'r, 's>(
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn definition<'s>(input: &'s str) -> Res<&'s str, Vec<Object<'s>>> {
|
fn definition<'s>(input: &'s str) -> Res<&'s str, Vec<Object<'s>>> {
|
||||||
Ok((input, vec![]))
|
Ok((input, vec![]))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn footnote_definition_end<'r, 's>(
|
fn footnote_definition_end<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -170,7 +170,7 @@ fn footnote_definition_end<'r, 's>(
|
|||||||
tag("]")(input)
|
tag("]")(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn get_bracket_depth<'r, 's>(
|
fn get_bracket_depth<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
) -> Option<&'r FootnoteReferenceDefinition<'s>> {
|
) -> Option<&'r FootnoteReferenceDefinition<'s>> {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ use crate::parser::util::start_of_line;
|
|||||||
use crate::parser::Element;
|
use crate::parser::Element;
|
||||||
use crate::parser::Paragraph;
|
use crate::parser::Paragraph;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn greater_block<'r, 's>(
|
pub fn greater_block<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -107,17 +107,17 @@ pub fn greater_block<'r, 's>(
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn name<'s>(input: &'s str) -> Res<&'s str, &'s str> {
|
fn name<'s>(input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
is_not(" \t\r\n")(input)
|
is_not(" \t\r\n")(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn parameters<'s>(input: &'s str) -> Res<&'s str, &'s str> {
|
fn parameters<'s>(input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
is_not("\r\n")(input)
|
is_not("\r\n")(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn greater_block_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn greater_block_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
start_of_line(context, input)?;
|
start_of_line(context, input)?;
|
||||||
let current_name: &str = get_context_greater_block_name(context).ok_or(nom::Err::Error(
|
let current_name: &str = get_context_greater_block_name(context).ok_or(nom::Err::Error(
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ use crate::error::Res;
|
|||||||
use crate::parser::util::start_of_line;
|
use crate::parser::util::start_of_line;
|
||||||
use crate::parser::HorizontalRule;
|
use crate::parser::HorizontalRule;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn horizontal_rule<'r, 's>(
|
pub fn horizontal_rule<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ use crate::parser::util::exit_matcher_parser;
|
|||||||
use crate::parser::util::get_consumed;
|
use crate::parser::util::get_consumed;
|
||||||
use crate::parser::InlineBabelCall;
|
use crate::parser::InlineBabelCall;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn inline_babel_call<'r, 's>(
|
pub fn inline_babel_call<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -36,7 +36,7 @@ pub fn inline_babel_call<'r, 's>(
|
|||||||
Ok((remaining, InlineBabelCall { source }))
|
Ok((remaining, InlineBabelCall { source }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn name<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn name<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let parser_context =
|
let parser_context =
|
||||||
context.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
|
context.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||||
@@ -50,12 +50,12 @@ fn name<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s st
|
|||||||
Ok((remaining, name))
|
Ok((remaining, name))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn name_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn name_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
recognize(one_of("[("))(input)
|
recognize(one_of("[("))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn header<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn header<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let (remaining, _) = tag("[")(input)?;
|
let (remaining, _) = tag("[")(input)?;
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ fn header<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s
|
|||||||
Ok((remaining, name))
|
Ok((remaining, name))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn header_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn header_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let context_depth = get_bracket_depth(context)
|
let context_depth = get_bracket_depth(context)
|
||||||
.expect("This function should only be called from inside an inline babel call header.");
|
.expect("This function should only be called from inside an inline babel call header.");
|
||||||
@@ -100,7 +100,7 @@ fn header_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str,
|
|||||||
alt((tag("]"), line_ending))(input)
|
alt((tag("]"), line_ending))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn argument<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn argument<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let (remaining, _) = tag("(")(input)?;
|
let (remaining, _) = tag("(")(input)?;
|
||||||
|
|
||||||
@@ -122,7 +122,7 @@ fn argument<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'
|
|||||||
Ok((remaining, name))
|
Ok((remaining, name))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn argument_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn argument_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let context_depth = get_bracket_depth(context)
|
let context_depth = get_bracket_depth(context)
|
||||||
.expect("This function should only be called from inside an inline babel call argument.");
|
.expect("This function should only be called from inside an inline babel call argument.");
|
||||||
@@ -145,7 +145,7 @@ fn argument_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str
|
|||||||
alt((tag(")"), line_ending))(input)
|
alt((tag(")"), line_ending))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn get_bracket_depth<'r, 's>(context: Context<'r, 's>) -> Option<&'r BabelHeaderBracket<'s>> {
|
pub fn get_bracket_depth<'r, 's>(context: Context<'r, 's>) -> Option<&'r BabelHeaderBracket<'s>> {
|
||||||
for node in context.iter() {
|
for node in context.iter() {
|
||||||
match node.get_data() {
|
match node.get_data() {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use nom::combinator::opt;
|
|||||||
use nom::combinator::recognize;
|
use nom::combinator::recognize;
|
||||||
use nom::combinator::verify;
|
use nom::combinator::verify;
|
||||||
use nom::multi::many_till;
|
use nom::multi::many_till;
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
use tracing::span;
|
use tracing::span;
|
||||||
|
|
||||||
use super::Context;
|
use super::Context;
|
||||||
@@ -22,7 +23,7 @@ use crate::parser::util::exit_matcher_parser;
|
|||||||
use crate::parser::util::get_consumed;
|
use crate::parser::util::get_consumed;
|
||||||
use crate::parser::InlineSourceBlock;
|
use crate::parser::InlineSourceBlock;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn inline_source_block<'r, 's>(
|
pub fn inline_source_block<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -36,7 +37,7 @@ pub fn inline_source_block<'r, 's>(
|
|||||||
Ok((remaining, InlineSourceBlock { source }))
|
Ok((remaining, InlineSourceBlock { source }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn lang<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn lang<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let parser_context =
|
let parser_context =
|
||||||
context.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
|
context.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||||
@@ -50,12 +51,12 @@ fn lang<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s st
|
|||||||
Ok((remaining, lang))
|
Ok((remaining, lang))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn lang_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn lang_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
recognize(one_of("[{"))(input)
|
recognize(one_of("[{"))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn header<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn header<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let (remaining, _) = tag("[")(input)?;
|
let (remaining, _) = tag("[")(input)?;
|
||||||
|
|
||||||
@@ -79,7 +80,7 @@ fn header<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s
|
|||||||
Ok((remaining, header_contents))
|
Ok((remaining, header_contents))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn header_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn header_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let context_depth = get_bracket_depth(context)
|
let context_depth = get_bracket_depth(context)
|
||||||
.expect("This function should only be called from inside an inline source block header.");
|
.expect("This function should only be called from inside an inline source block header.");
|
||||||
@@ -109,7 +110,7 @@ fn header_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str,
|
|||||||
line_ending(input)
|
line_ending(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn body<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn body<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let (remaining, _) = tag("{")(input)?;
|
let (remaining, _) = tag("{")(input)?;
|
||||||
|
|
||||||
@@ -130,18 +131,20 @@ fn body<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s st
|
|||||||
parser_with_context!(exit_matcher_parser)(&parser_context),
|
parser_with_context!(exit_matcher_parser)(&parser_context),
|
||||||
))(remaining)?;
|
))(remaining)?;
|
||||||
let (remaining, _) = {
|
let (remaining, _) = {
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
let span = span!(
|
let span = span!(
|
||||||
tracing::Level::DEBUG,
|
tracing::Level::DEBUG,
|
||||||
"outside end body",
|
"outside end body",
|
||||||
remaining = remaining
|
remaining = remaining
|
||||||
);
|
);
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
let _enter = span.enter();
|
let _enter = span.enter();
|
||||||
tag("}")(remaining)?
|
tag("}")(remaining)?
|
||||||
};
|
};
|
||||||
Ok((remaining, body_contents))
|
Ok((remaining, body_contents))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn body_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn body_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let context_depth = get_bracket_depth(context)
|
let context_depth = get_bracket_depth(context)
|
||||||
.expect("This function should only be called from inside an inline source block body.");
|
.expect("This function should only be called from inside an inline source block body.");
|
||||||
@@ -162,12 +165,14 @@ fn body_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
let span = span!(
|
let span = span!(
|
||||||
tracing::Level::DEBUG,
|
tracing::Level::DEBUG,
|
||||||
"inside end body",
|
"inside end body",
|
||||||
remaining = input,
|
remaining = input,
|
||||||
current_depth = current_depth
|
current_depth = current_depth
|
||||||
);
|
);
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
let _enter = span.enter();
|
let _enter = span.enter();
|
||||||
|
|
||||||
if current_depth == 0 {
|
if current_depth == 0 {
|
||||||
@@ -181,7 +186,7 @@ fn body_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'
|
|||||||
line_ending(input)
|
line_ending(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn get_bracket_depth<'r, 's>(
|
pub fn get_bracket_depth<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
) -> Option<&'r InlineSourceBlockBracket<'s>> {
|
) -> Option<&'r InlineSourceBlockBracket<'s>> {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ use crate::error::Res;
|
|||||||
use crate::parser::util::start_of_line;
|
use crate::parser::util::start_of_line;
|
||||||
use crate::parser::Keyword;
|
use crate::parser::Keyword;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn keyword<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Keyword<'s>> {
|
pub fn keyword<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Keyword<'s>> {
|
||||||
start_of_line(context, input)?;
|
start_of_line(context, input)?;
|
||||||
// TODO: When key is a member of org-element-parsed-keywords, value can contain the standard set objects, excluding footnote references.
|
// TODO: When key is a member of org-element-parsed-keywords, value can contain the standard set objects, excluding footnote references.
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ use crate::parser::util::exit_matcher_parser;
|
|||||||
use crate::parser::util::start_of_line;
|
use crate::parser::util::start_of_line;
|
||||||
use crate::parser::LatexEnvironment;
|
use crate::parser::LatexEnvironment;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn latex_environment<'r, 's>(
|
pub fn latex_environment<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -51,12 +51,15 @@ pub fn latex_environment<'r, 's>(
|
|||||||
Ok((remaining, LatexEnvironment { source }))
|
Ok((remaining, LatexEnvironment { source }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn name<'s>(input: &'s str) -> Res<&'s str, &'s str> {
|
fn name<'s>(input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
take_while1(|c: char| c.is_alphanumeric() || c == '*')(input)
|
take_while1(|c: char| c.is_alphanumeric() || c == '*')(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug", skip(end_matcher))]
|
#[cfg_attr(
|
||||||
|
feature = "tracing",
|
||||||
|
tracing::instrument(ret, level = "debug", skip(end_matcher))
|
||||||
|
)]
|
||||||
pub fn contents<'r, 's, F: Fn(Context<'r, 's>, &'s str) -> Res<&'s str, &'s str>>(
|
pub fn contents<'r, 's, F: Fn(Context<'r, 's>, &'s str) -> Res<&'s str, &'s str>>(
|
||||||
end_matcher: F,
|
end_matcher: F,
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
@@ -82,7 +85,7 @@ fn latex_environment_end(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn _latex_environment_end<'r, 's, 'x>(
|
fn _latex_environment_end<'r, 's, 'x>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ use crate::parser::util::get_consumed;
|
|||||||
use crate::parser::util::get_one_before;
|
use crate::parser::util::get_one_before;
|
||||||
use crate::parser::LatexFragment;
|
use crate::parser::LatexFragment;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn latex_fragment<'r, 's>(
|
pub fn latex_fragment<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -41,7 +41,7 @@ pub fn latex_fragment<'r, 's>(
|
|||||||
Ok((remaining, LatexFragment { source }))
|
Ok((remaining, LatexFragment { source }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn raw_latex_fragment<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn raw_latex_fragment<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let (remaining, _) = tag("\\")(input)?;
|
let (remaining, _) = tag("\\")(input)?;
|
||||||
let (remaining, _) = name(context, remaining)?;
|
let (remaining, _) = name(context, remaining)?;
|
||||||
@@ -51,12 +51,12 @@ fn raw_latex_fragment<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&
|
|||||||
Ok((remaining, source))
|
Ok((remaining, source))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn name<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn name<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
alpha1(input)
|
alpha1(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn brackets<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn brackets<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let (remaining, body) = alt((
|
let (remaining, body) = alt((
|
||||||
recognize(tuple((
|
recognize(tuple((
|
||||||
@@ -85,7 +85,7 @@ fn brackets<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'
|
|||||||
Ok((remaining, body))
|
Ok((remaining, body))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn escaped_parenthesis_fragment<'r, 's>(
|
fn escaped_parenthesis_fragment<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -104,7 +104,7 @@ fn escaped_parenthesis_fragment<'r, 's>(
|
|||||||
Ok((remaining, source))
|
Ok((remaining, source))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn escaped_bracket_fragment<'r, 's>(
|
fn escaped_bracket_fragment<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -123,7 +123,7 @@ fn escaped_bracket_fragment<'r, 's>(
|
|||||||
Ok((remaining, source))
|
Ok((remaining, source))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn double_dollar_fragment<'r, 's>(
|
fn double_dollar_fragment<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -143,7 +143,7 @@ fn double_dollar_fragment<'r, 's>(
|
|||||||
Ok((remaining, source))
|
Ok((remaining, source))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn dollar_char_fragment<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn dollar_char_fragment<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let (_, _) = pre(context, input)?;
|
let (_, _) = pre(context, input)?;
|
||||||
let (remaining, _) = tag("$")(input)?;
|
let (remaining, _) = tag("$")(input)?;
|
||||||
@@ -155,7 +155,7 @@ fn dollar_char_fragment<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res
|
|||||||
Ok((remaining, source))
|
Ok((remaining, source))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn pre<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, ()> {
|
pub fn pre<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, ()> {
|
||||||
let document_root = context.get_document_root().unwrap();
|
let document_root = context.get_document_root().unwrap();
|
||||||
let preceding_character = get_one_before(document_root, input)
|
let preceding_character = get_one_before(document_root, input)
|
||||||
@@ -169,7 +169,7 @@ pub fn pre<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, ()>
|
|||||||
Ok((input, ()))
|
Ok((input, ()))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn post<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, ()> {
|
pub fn post<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, ()> {
|
||||||
// TODO: What about eof? Test to find out.
|
// TODO: What about eof? Test to find out.
|
||||||
|
|
||||||
@@ -178,7 +178,7 @@ pub fn post<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, ()
|
|||||||
Ok((remaining, ()))
|
Ok((remaining, ()))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn bordered_dollar_fragment<'r, 's>(
|
fn bordered_dollar_fragment<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -208,12 +208,12 @@ fn bordered_dollar_fragment<'r, 's>(
|
|||||||
Ok((remaining, source))
|
Ok((remaining, source))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn open_border<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
pub fn open_border<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
recognize(verify(none_of(".,;$"), |c| !c.is_whitespace()))(input)
|
recognize(verify(none_of(".,;$"), |c| !c.is_whitespace()))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn close_border<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, ()> {
|
pub fn close_border<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, ()> {
|
||||||
let document_root = context.get_document_root().unwrap();
|
let document_root = context.get_document_root().unwrap();
|
||||||
let preceding_character = get_one_before(document_root, input)
|
let preceding_character = get_one_before(document_root, input)
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ use crate::parser::util::get_consumed;
|
|||||||
use crate::parser::util::start_of_line;
|
use crate::parser::util::start_of_line;
|
||||||
use crate::parser::util::text_until_exit;
|
use crate::parser::util::text_until_exit;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn verse_block<'r, 's>(
|
pub fn verse_block<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -80,7 +80,7 @@ pub fn verse_block<'r, 's>(
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn comment_block<'r, 's>(
|
pub fn comment_block<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -116,7 +116,7 @@ pub fn comment_block<'r, 's>(
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn example_block<'r, 's>(
|
pub fn example_block<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -152,7 +152,7 @@ pub fn example_block<'r, 's>(
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn export_block<'r, 's>(
|
pub fn export_block<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -189,7 +189,7 @@ pub fn export_block<'r, 's>(
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn src_block<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, SrcBlock<'s>> {
|
pub fn src_block<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, SrcBlock<'s>> {
|
||||||
let (remaining, name) = lesser_block_begin("src")(context, input)?;
|
let (remaining, name) = lesser_block_begin("src")(context, input)?;
|
||||||
// https://orgmode.org/worg/org-syntax.html#Blocks claims that data is mandatory and must follow the LANGUAGE SWITCHES ARGUMENTS pattern but testing has shown that no data and incorrect data here will still parse to a src block.
|
// https://orgmode.org/worg/org-syntax.html#Blocks claims that data is mandatory and must follow the LANGUAGE SWITCHES ARGUMENTS pattern but testing has shown that no data and incorrect data here will still parse to a src block.
|
||||||
@@ -200,7 +200,7 @@ pub fn src_block<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s st
|
|||||||
.with_additional_node(ContextElement::ConsumeTrailingWhitespace(true))
|
.with_additional_node(ContextElement::ConsumeTrailingWhitespace(true))
|
||||||
.with_additional_node(ContextElement::Context("lesser block"))
|
.with_additional_node(ContextElement::Context("lesser block"))
|
||||||
.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
|
.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||||
class: ExitClass::Beta,
|
class: ExitClass::Alpha,
|
||||||
exit_matcher: &lesser_block_end_specialized,
|
exit_matcher: &lesser_block_end_specialized,
|
||||||
}));
|
}));
|
||||||
let parameters = match parameters {
|
let parameters = match parameters {
|
||||||
@@ -223,12 +223,12 @@ pub fn src_block<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s st
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn name<'s>(input: &'s str) -> Res<&'s str, &'s str> {
|
fn name<'s>(input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
is_not(" \t\r\n")(input)
|
is_not(" \t\r\n")(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn data<'s>(input: &'s str) -> Res<&'s str, &'s str> {
|
fn data<'s>(input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
is_not("\r\n")(input)
|
is_not("\r\n")(input)
|
||||||
}
|
}
|
||||||
@@ -238,16 +238,25 @@ fn lesser_block_end(
|
|||||||
) -> impl for<'r, 's> Fn(Context<'r, 's>, &'s str) -> Res<&'s str, &'s str> {
|
) -> impl for<'r, 's> Fn(Context<'r, 's>, &'s str) -> Res<&'s str, &'s str> {
|
||||||
let current_name_lower = current_name.to_lowercase();
|
let current_name_lower = current_name.to_lowercase();
|
||||||
move |context: Context, input: &str| {
|
move |context: Context, input: &str| {
|
||||||
|
_lesser_block_end(context, input, current_name_lower.as_str())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
|
fn _lesser_block_end<'r, 's, 'x>(
|
||||||
|
context: Context<'r, 's>,
|
||||||
|
input: &'s str,
|
||||||
|
current_name_lower: &'x str,
|
||||||
|
) -> Res<&'s str, &'s str> {
|
||||||
start_of_line(context, input)?;
|
start_of_line(context, input)?;
|
||||||
let (remaining, _leading_whitespace) = space0(input)?;
|
let (remaining, _leading_whitespace) = space0(input)?;
|
||||||
let (remaining, (_begin, _name, _ws)) = tuple((
|
let (remaining, (_begin, _name, _ws)) = tuple((
|
||||||
tag_no_case("#+end_"),
|
tag_no_case("#+end_"),
|
||||||
tag_no_case(current_name_lower.as_str()),
|
tag_no_case(current_name_lower),
|
||||||
alt((eof, line_ending)),
|
alt((eof, line_ending)),
|
||||||
))(remaining)?;
|
))(remaining)?;
|
||||||
let source = get_consumed(input, remaining);
|
let source = get_consumed(input, remaining);
|
||||||
Ok((remaining, source))
|
Ok((remaining, source))
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lesser_block_begin(
|
fn lesser_block_begin(
|
||||||
@@ -255,6 +264,16 @@ fn lesser_block_begin(
|
|||||||
) -> impl for<'r, 's> Fn(Context<'r, 's>, &'s str) -> Res<&'s str, &'s str> {
|
) -> impl for<'r, 's> Fn(Context<'r, 's>, &'s str) -> Res<&'s str, &'s str> {
|
||||||
let current_name_lower = current_name.to_lowercase();
|
let current_name_lower = current_name.to_lowercase();
|
||||||
move |context: Context, input: &str| {
|
move |context: Context, input: &str| {
|
||||||
|
_lesser_block_begin(context, input, current_name_lower.as_str())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
|
fn _lesser_block_begin<'r, 's, 'x>(
|
||||||
|
context: Context<'r, 's>,
|
||||||
|
input: &'s str,
|
||||||
|
current_name_lower: &'x str,
|
||||||
|
) -> Res<&'s str, &'s str> {
|
||||||
start_of_line(context, input)?;
|
start_of_line(context, input)?;
|
||||||
let (remaining, _leading_whitespace) = space0(input)?;
|
let (remaining, _leading_whitespace) = space0(input)?;
|
||||||
let (remaining, (_begin, name)) = tuple((
|
let (remaining, (_begin, name)) = tuple((
|
||||||
@@ -264,5 +283,4 @@ fn lesser_block_begin(
|
|||||||
}),
|
}),
|
||||||
))(remaining)?;
|
))(remaining)?;
|
||||||
Ok((remaining, name))
|
Ok((remaining, name))
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ use crate::parser::util::get_current_line_before_position;
|
|||||||
use crate::parser::util::get_one_before;
|
use crate::parser::util::get_one_before;
|
||||||
use crate::parser::LineBreak;
|
use crate::parser::LineBreak;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn line_break<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, LineBreak<'s>> {
|
pub fn line_break<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, LineBreak<'s>> {
|
||||||
let (remaining, _) = pre(context, input)?;
|
let (remaining, _) = pre(context, input)?;
|
||||||
let (remaining, _) = tag(r#"\\"#)(remaining)?;
|
let (remaining, _) = tag(r#"\\"#)(remaining)?;
|
||||||
@@ -23,7 +23,7 @@ pub fn line_break<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s s
|
|||||||
Ok((remaining, LineBreak { source }))
|
Ok((remaining, LineBreak { source }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn pre<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, ()> {
|
fn pre<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, ()> {
|
||||||
let document_root = context.get_document_root().unwrap();
|
let document_root = context.get_document_root().unwrap();
|
||||||
let preceding_character = get_one_before(document_root, input)
|
let preceding_character = get_one_before(document_root, input)
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ use crate::parser::target::target;
|
|||||||
use crate::parser::text_markup::text_markup;
|
use crate::parser::text_markup::text_markup;
|
||||||
use crate::parser::timestamp::timestamp;
|
use crate::parser::timestamp::timestamp;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn standard_set_object<'r, 's>(
|
pub fn standard_set_object<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -87,7 +87,7 @@ pub fn standard_set_object<'r, 's>(
|
|||||||
))(input)
|
))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn minimal_set_object<'r, 's>(
|
pub fn minimal_set_object<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -110,7 +110,7 @@ pub fn minimal_set_object<'r, 's>(
|
|||||||
))(input)
|
))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn any_object_except_plain_text<'r, 's>(
|
pub fn any_object_except_plain_text<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -167,7 +167,7 @@ pub fn any_object_except_plain_text<'r, 's>(
|
|||||||
))(input)
|
))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn regular_link_description_object_set<'r, 's>(
|
pub fn regular_link_description_object_set<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use crate::parser::parser_with_context::parser_with_context;
|
|||||||
use crate::parser::util::exit_matcher_parser;
|
use crate::parser::util::exit_matcher_parser;
|
||||||
use crate::parser::util::get_consumed;
|
use crate::parser::util::get_consumed;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn org_macro<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, OrgMacro<'s>> {
|
pub fn org_macro<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, OrgMacro<'s>> {
|
||||||
let (remaining, _) = tag("{{{")(input)?;
|
let (remaining, _) = tag("{{{")(input)?;
|
||||||
let (remaining, macro_name) = org_macro_name(context, remaining)?;
|
let (remaining, macro_name) = org_macro_name(context, remaining)?;
|
||||||
@@ -32,7 +32,7 @@ pub fn org_macro<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s st
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn org_macro_name<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn org_macro_name<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let (remaining, _) = verify(anychar, |c| c.is_alphabetic())(input)?;
|
let (remaining, _) = verify(anychar, |c| c.is_alphabetic())(input)?;
|
||||||
let (remaining, _) = many0(verify(anychar, |c| {
|
let (remaining, _) = many0(verify(anychar, |c| {
|
||||||
@@ -42,7 +42,7 @@ fn org_macro_name<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s s
|
|||||||
Ok((remaining, source))
|
Ok((remaining, source))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn org_macro_args<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Vec<&'s str>> {
|
fn org_macro_args<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Vec<&'s str>> {
|
||||||
let (remaining, _) = tag("(")(input)?;
|
let (remaining, _) = tag("(")(input)?;
|
||||||
let (remaining, args) =
|
let (remaining, args) =
|
||||||
@@ -52,7 +52,7 @@ fn org_macro_args<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s s
|
|||||||
Ok((remaining, args))
|
Ok((remaining, args))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn org_macro_arg<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn org_macro_arg<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let mut remaining = input;
|
let mut remaining = input;
|
||||||
let mut escaping: bool = false;
|
let mut escaping: bool = false;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ use crate::parser::parser_with_context::parser_with_context;
|
|||||||
use crate::parser::util::exit_matcher_parser;
|
use crate::parser::util::exit_matcher_parser;
|
||||||
use crate::parser::util::start_of_line;
|
use crate::parser::util::start_of_line;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn paragraph<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Paragraph<'s>> {
|
pub fn paragraph<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Paragraph<'s>> {
|
||||||
let parser_context =
|
let parser_context =
|
||||||
context.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
|
context.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||||
@@ -42,7 +42,7 @@ pub fn paragraph<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s st
|
|||||||
Ok((remaining, Paragraph { source, children }))
|
Ok((remaining, Paragraph { source, children }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn paragraph_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn paragraph_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let non_paragraph_element_matcher = parser_with_context!(element(false))(context);
|
let non_paragraph_element_matcher = parser_with_context!(element(false))(context);
|
||||||
let start_of_line_matcher = parser_with_context!(start_of_line)(&context);
|
let start_of_line_matcher = parser_with_context!(start_of_line)(&context);
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ impl<'r, 's> ContextTree<'r, 's> {
|
|||||||
self.tree.iter()
|
self.tree.iter()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn check_exit_matcher(
|
pub fn check_exit_matcher(
|
||||||
&'r self,
|
&'r self,
|
||||||
i: &'s str,
|
i: &'s str,
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ use crate::parser::util::get_consumed;
|
|||||||
use crate::parser::util::get_one_before;
|
use crate::parser::util::get_one_before;
|
||||||
use crate::parser::util::WORD_CONSTITUENT_CHARACTERS;
|
use crate::parser::util::WORD_CONSTITUENT_CHARACTERS;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn plain_link<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, PlainLink<'s>> {
|
pub fn plain_link<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, PlainLink<'s>> {
|
||||||
let (remaining, _) = pre(context, input)?;
|
let (remaining, _) = pre(context, input)?;
|
||||||
let (remaining, proto) = protocol(context, remaining)?;
|
let (remaining, proto) = protocol(context, remaining)?;
|
||||||
@@ -41,7 +41,7 @@ pub fn plain_link<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s s
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn pre<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, ()> {
|
fn pre<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, ()> {
|
||||||
let document_root = context.get_document_root().unwrap();
|
let document_root = context.get_document_root().unwrap();
|
||||||
let preceding_character = get_one_before(document_root, input)
|
let preceding_character = get_one_before(document_root, input)
|
||||||
@@ -61,13 +61,13 @@ fn pre<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, ()> {
|
|||||||
Ok((input, ()))
|
Ok((input, ()))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn post<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, ()> {
|
fn post<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, ()> {
|
||||||
let (remaining, _) = alt((eof, recognize(none_of(WORD_CONSTITUENT_CHARACTERS))))(input)?;
|
let (remaining, _) = alt((eof, recognize(none_of(WORD_CONSTITUENT_CHARACTERS))))(input)?;
|
||||||
Ok((remaining, ()))
|
Ok((remaining, ()))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn protocol<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
pub fn protocol<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
// TODO: This should be defined by org-link-parameters
|
// TODO: This should be defined by org-link-parameters
|
||||||
let (remaining, proto) = alt((
|
let (remaining, proto) = alt((
|
||||||
@@ -102,7 +102,7 @@ pub fn protocol<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str
|
|||||||
Ok((remaining, proto))
|
Ok((remaining, proto))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn path_plain<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn path_plain<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
// TODO: "optionally containing parenthesis-wrapped non-whitespace non-bracket substrings up to a depth of two. The string must end with either a non-punctation non-whitespace character, a forwards slash, or a parenthesis-wrapped substring"
|
// TODO: "optionally containing parenthesis-wrapped non-whitespace non-bracket substrings up to a depth of two. The string must end with either a non-punctation non-whitespace character, a forwards slash, or a parenthesis-wrapped substring"
|
||||||
let parser_context =
|
let parser_context =
|
||||||
@@ -117,7 +117,7 @@ fn path_plain<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str,
|
|||||||
Ok((remaining, path))
|
Ok((remaining, path))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn path_plain_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn path_plain_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
recognize(one_of(" \t\r\n()[]<>"))(input)
|
recognize(one_of(" \t\r\n()[]<>"))(input)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ use nom::multi::many_till;
|
|||||||
use nom::sequence::preceded;
|
use nom::sequence::preceded;
|
||||||
use nom::sequence::terminated;
|
use nom::sequence::terminated;
|
||||||
use nom::sequence::tuple;
|
use nom::sequence::tuple;
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
use tracing::span;
|
use tracing::span;
|
||||||
|
|
||||||
use super::greater_element::PlainList;
|
use super::greater_element::PlainList;
|
||||||
@@ -33,7 +34,7 @@ use crate::parser::util::exit_matcher_parser;
|
|||||||
use crate::parser::util::get_consumed;
|
use crate::parser::util::get_consumed;
|
||||||
use crate::parser::util::start_of_line;
|
use crate::parser::util::start_of_line;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn plain_list<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, PlainList<'s>> {
|
pub fn plain_list<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, PlainList<'s>> {
|
||||||
let parser_context = context
|
let parser_context = context
|
||||||
.with_additional_node(ContextElement::Context("plain list"))
|
.with_additional_node(ContextElement::Context("plain list"))
|
||||||
@@ -63,7 +64,9 @@ pub fn plain_list<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s s
|
|||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
// Don't consume, yes exit matcher
|
// Don't consume, yes exit matcher
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
let span = span!(tracing::Level::DEBUG, "first");
|
let span = span!(tracing::Level::DEBUG, "first");
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
let _enter = span.enter();
|
let _enter = span.enter();
|
||||||
|
|
||||||
let last_item_then_exit = tuple((without_consume_matcher, exit_matcher))(remaining);
|
let last_item_then_exit = tuple((without_consume_matcher, exit_matcher))(remaining);
|
||||||
@@ -82,7 +85,9 @@ pub fn plain_list<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s s
|
|||||||
|
|
||||||
{
|
{
|
||||||
// Consume, additional item
|
// Consume, additional item
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
let span = span!(tracing::Level::DEBUG, "second");
|
let span = span!(tracing::Level::DEBUG, "second");
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
let _enter = span.enter();
|
let _enter = span.enter();
|
||||||
|
|
||||||
let not_last_item =
|
let not_last_item =
|
||||||
@@ -104,7 +109,9 @@ pub fn plain_list<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s s
|
|||||||
|
|
||||||
{
|
{
|
||||||
// Don't consume, no additional item
|
// Don't consume, no additional item
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
let span = span!(tracing::Level::DEBUG, "third");
|
let span = span!(tracing::Level::DEBUG, "third");
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
let _enter = span.enter();
|
let _enter = span.enter();
|
||||||
|
|
||||||
let last_item_then_exit = without_consume_matcher(remaining);
|
let last_item_then_exit = without_consume_matcher(remaining);
|
||||||
@@ -138,7 +145,7 @@ pub fn plain_list<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s s
|
|||||||
Ok((remaining, PlainList { source, children }))
|
Ok((remaining, PlainList { source, children }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn plain_list_item<'r, 's>(
|
pub fn plain_list_item<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -208,7 +215,7 @@ pub fn plain_list_item<'r, 's>(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn bullet<'s>(i: &'s str) -> Res<&'s str, &'s str> {
|
fn bullet<'s>(i: &'s str) -> Res<&'s str, &'s str> {
|
||||||
alt((
|
alt((
|
||||||
tag("*"),
|
tag("*"),
|
||||||
@@ -218,12 +225,12 @@ fn bullet<'s>(i: &'s str) -> Res<&'s str, &'s str> {
|
|||||||
))(i)
|
))(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn counter<'s>(i: &'s str) -> Res<&'s str, &'s str> {
|
fn counter<'s>(i: &'s str) -> Res<&'s str, &'s str> {
|
||||||
alt((recognize(one_of("abcdefghijklmnopqrstuvwxyz")), digit1))(i)
|
alt((recognize(one_of("abcdefghijklmnopqrstuvwxyz")), digit1))(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn plain_list_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn plain_list_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let start_of_line_matcher = parser_with_context!(start_of_line)(context);
|
let start_of_line_matcher = parser_with_context!(start_of_line)(context);
|
||||||
recognize(tuple((
|
recognize(tuple((
|
||||||
@@ -232,7 +239,7 @@ fn plain_list_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s s
|
|||||||
)))(input)
|
)))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn plain_list_item_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn plain_list_item_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let current_item_indent_level: &usize =
|
let current_item_indent_level: &usize =
|
||||||
get_context_item_indent(context).ok_or(nom::Err::Error(CustomError::MyError(MyError(
|
get_context_item_indent(context).ok_or(nom::Err::Error(CustomError::MyError(MyError(
|
||||||
@@ -248,7 +255,7 @@ fn plain_list_item_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<
|
|||||||
))(input)
|
))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn line_indented_lte<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn line_indented_lte<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let current_item_indent_level: &usize =
|
let current_item_indent_level: &usize =
|
||||||
get_context_item_indent(context).ok_or(nom::Err::Error(CustomError::MyError(MyError(
|
get_context_item_indent(context).ok_or(nom::Err::Error(CustomError::MyError(MyError(
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ use crate::parser::object_parser::any_object_except_plain_text;
|
|||||||
use crate::parser::parser_with_context::parser_with_context;
|
use crate::parser::parser_with_context::parser_with_context;
|
||||||
use crate::parser::util::exit_matcher_parser;
|
use crate::parser::util::exit_matcher_parser;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn plain_text<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, PlainText<'s>> {
|
pub fn plain_text<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, PlainText<'s>> {
|
||||||
let (remaining, source) = recognize(verify(
|
let (remaining, source) = recognize(verify(
|
||||||
many_till(
|
many_till(
|
||||||
@@ -32,13 +32,13 @@ pub fn plain_text<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s s
|
|||||||
Ok((remaining, PlainText { source }))
|
Ok((remaining, PlainText { source }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn plain_text_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn plain_text_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
recognize(parser_with_context!(any_object_except_plain_text)(context))(input)
|
recognize(parser_with_context!(any_object_except_plain_text)(context))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'x> RematchObject<'x> for PlainText<'x> {
|
impl<'x> RematchObject<'x> for PlainText<'x> {
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn rematch_object<'r, 's>(
|
fn rematch_object<'r, 's>(
|
||||||
&'x self,
|
&'x self,
|
||||||
_context: Context<'r, 's>,
|
_context: Context<'r, 's>,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ use crate::parser::lesser_element::Planning;
|
|||||||
use crate::parser::util::get_consumed;
|
use crate::parser::util::get_consumed;
|
||||||
use crate::parser::util::start_of_line;
|
use crate::parser::util::start_of_line;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn planning<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Planning<'s>> {
|
pub fn planning<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Planning<'s>> {
|
||||||
start_of_line(context, input)?;
|
start_of_line(context, input)?;
|
||||||
let (remaining, _leading_whitespace) = space0(input)?;
|
let (remaining, _leading_whitespace) = space0(input)?;
|
||||||
@@ -27,7 +27,7 @@ pub fn planning<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str
|
|||||||
Ok((remaining, Planning { source }))
|
Ok((remaining, Planning { source }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn planning_parameter<'s>(input: &'s str) -> Res<&'s str, &'s str> {
|
fn planning_parameter<'s>(input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let (remaining, _planning_type) = alt((
|
let (remaining, _planning_type) = alt((
|
||||||
tag_no_case("DEADLINE"),
|
tag_no_case("DEADLINE"),
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ use crate::parser::util::immediate_in_section;
|
|||||||
use crate::parser::util::maybe_consume_trailing_whitespace_if_not_exiting;
|
use crate::parser::util::maybe_consume_trailing_whitespace_if_not_exiting;
|
||||||
use crate::parser::util::start_of_line;
|
use crate::parser::util::start_of_line;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn property_drawer<'r, 's>(
|
pub fn property_drawer<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -71,7 +71,7 @@ pub fn property_drawer<'r, 's>(
|
|||||||
Ok((remaining, PropertyDrawer { source, children }))
|
Ok((remaining, PropertyDrawer { source, children }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn property_drawer_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn property_drawer_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
recognize(tuple((
|
recognize(tuple((
|
||||||
parser_with_context!(start_of_line)(context),
|
parser_with_context!(start_of_line)(context),
|
||||||
@@ -82,7 +82,7 @@ fn property_drawer_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<
|
|||||||
)))(input)
|
)))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn node_property<'r, 's>(
|
fn node_property<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -121,7 +121,7 @@ fn node_property<'r, 's>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn node_property_name<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn node_property_name<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let parser_context =
|
let parser_context =
|
||||||
context.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
|
context.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||||
@@ -138,7 +138,7 @@ fn node_property_name<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&
|
|||||||
Ok((remaining, name))
|
Ok((remaining, name))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn node_property_name_end<'r, 's>(
|
fn node_property_name_end<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ use crate::parser::util::get_consumed;
|
|||||||
use crate::parser::RadioLink;
|
use crate::parser::RadioLink;
|
||||||
use crate::parser::RadioTarget;
|
use crate::parser::RadioTarget;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn radio_link<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, RadioLink<'s>> {
|
pub fn radio_link<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, RadioLink<'s>> {
|
||||||
let radio_targets = context
|
let radio_targets = context
|
||||||
.iter()
|
.iter()
|
||||||
@@ -48,7 +48,7 @@ pub fn radio_link<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s s
|
|||||||
))))
|
))))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn rematch_target<'x, 'r, 's>(
|
pub fn rematch_target<'x, 'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
target: &'x Vec<Object<'x>>,
|
target: &'x Vec<Object<'x>>,
|
||||||
@@ -79,7 +79,7 @@ pub fn rematch_target<'x, 'r, 's>(
|
|||||||
Ok((remaining, new_matches))
|
Ok((remaining, new_matches))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn radio_target<'r, 's>(
|
pub fn radio_target<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -105,7 +105,7 @@ pub fn radio_target<'r, 's>(
|
|||||||
Ok((remaining, RadioTarget { source, children }))
|
Ok((remaining, RadioTarget { source, children }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn radio_target_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn radio_target_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
alt((tag("<"), tag(">"), line_ending))(input)
|
alt((tag("<"), tag(">"), line_ending))(input)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ use crate::parser::parser_context::ContextElement;
|
|||||||
use crate::parser::parser_context::ExitMatcherNode;
|
use crate::parser::parser_context::ExitMatcherNode;
|
||||||
use crate::parser::util::exit_matcher_parser;
|
use crate::parser::util::exit_matcher_parser;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn regular_link<'r, 's>(
|
pub fn regular_link<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -30,7 +30,7 @@ pub fn regular_link<'r, 's>(
|
|||||||
))(input)
|
))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn regular_link_without_description<'r, 's>(
|
pub fn regular_link_without_description<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -43,7 +43,7 @@ pub fn regular_link_without_description<'r, 's>(
|
|||||||
Ok((remaining, RegularLink { source }))
|
Ok((remaining, RegularLink { source }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn regular_link_with_description<'r, 's>(
|
pub fn regular_link_with_description<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -58,7 +58,7 @@ pub fn regular_link_with_description<'r, 's>(
|
|||||||
Ok((remaining, RegularLink { source }))
|
Ok((remaining, RegularLink { source }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn pathreg<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
pub fn pathreg<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let (remaining, path) = escaped(
|
let (remaining, path) = escaped(
|
||||||
take_till1(|c| match c {
|
take_till1(|c| match c {
|
||||||
@@ -71,7 +71,7 @@ pub fn pathreg<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str,
|
|||||||
Ok((remaining, path))
|
Ok((remaining, path))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn description<'r, 's>(
|
pub fn description<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -92,7 +92,7 @@ pub fn description<'r, 's>(
|
|||||||
Ok((remaining, children))
|
Ok((remaining, children))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn description_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn description_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
tag("]]")(input)
|
tag("]]")(input)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ pub enum Token<'s> {
|
|||||||
Atom(&'s str),
|
Atom(&'s str),
|
||||||
List(Vec<Token<'s>>),
|
List(Vec<Token<'s>>),
|
||||||
TextWithProperties(TextWithProperties<'s>),
|
TextWithProperties(TextWithProperties<'s>),
|
||||||
|
Vector(Vec<Token<'s>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -59,6 +60,10 @@ impl<'s> TextWithProperties<'s> {
|
|||||||
out.push('\\');
|
out.push('\\');
|
||||||
ParseState::Normal
|
ParseState::Normal
|
||||||
}
|
}
|
||||||
|
(ParseState::Escape, '"') => {
|
||||||
|
out.push('"');
|
||||||
|
ParseState::Normal
|
||||||
|
}
|
||||||
_ => todo!(),
|
_ => todo!(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -73,6 +78,13 @@ enum ParseState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'s> Token<'s> {
|
impl<'s> Token<'s> {
|
||||||
|
pub fn as_vector<'p>(&'p self) -> Result<&'p Vec<Token<'s>>, Box<dyn std::error::Error>> {
|
||||||
|
Ok(match self {
|
||||||
|
Token::Vector(children) => Ok(children),
|
||||||
|
_ => Err(format!("wrong token type {:?}", self)),
|
||||||
|
}?)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn as_list<'p>(&'p self) -> Result<&'p Vec<Token<'s>>, Box<dyn std::error::Error>> {
|
pub fn as_list<'p>(&'p self) -> Result<&'p Vec<Token<'s>>, Box<dyn std::error::Error>> {
|
||||||
Ok(match self {
|
Ok(match self {
|
||||||
Token::List(children) => Ok(children),
|
Token::List(children) => Ok(children),
|
||||||
@@ -120,7 +132,7 @@ impl<'s> Token<'s> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn sexp_with_padding<'s>(input: &'s str) -> Res<&'s str, Token<'s>> {
|
pub fn sexp_with_padding<'s>(input: &'s str) -> Res<&'s str, Token<'s>> {
|
||||||
let (remaining, _) = multispace0(input)?;
|
let (remaining, _) = multispace0(input)?;
|
||||||
let (remaining, tkn) = token(remaining)?;
|
let (remaining, tkn) = token(remaining)?;
|
||||||
@@ -128,18 +140,18 @@ pub fn sexp_with_padding<'s>(input: &'s str) -> Res<&'s str, Token<'s>> {
|
|||||||
Ok((remaining, tkn))
|
Ok((remaining, tkn))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn sexp<'s>(input: &'s str) -> Res<&'s str, Token<'s>> {
|
pub fn sexp<'s>(input: &'s str) -> Res<&'s str, Token<'s>> {
|
||||||
let (remaining, tkn) = token(input)?;
|
let (remaining, tkn) = token(input)?;
|
||||||
Ok((remaining, tkn))
|
Ok((remaining, tkn))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn token<'s>(input: &'s str) -> Res<&'s str, Token<'s>> {
|
fn token<'s>(input: &'s str) -> Res<&'s str, Token<'s>> {
|
||||||
alt((list, atom))(input)
|
alt((list, vector, atom))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn list<'s>(input: &'s str) -> Res<&'s str, Token<'s>> {
|
fn list<'s>(input: &'s str) -> Res<&'s str, Token<'s>> {
|
||||||
let (remaining, _) = tag("(")(input)?;
|
let (remaining, _) = tag("(")(input)?;
|
||||||
let (remaining, children) = delimited(
|
let (remaining, children) = delimited(
|
||||||
@@ -151,22 +163,39 @@ fn list<'s>(input: &'s str) -> Res<&'s str, Token<'s>> {
|
|||||||
Ok((remaining, Token::List(children)))
|
Ok((remaining, Token::List(children)))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn atom<'s>(input: &'s str) -> Res<&'s str, Token<'s>> {
|
fn vector<'s>(input: &'s str) -> Res<&'s str, Token<'s>> {
|
||||||
not(peek(tag(")")))(input)?;
|
let (remaining, _) = tag("[")(input)?;
|
||||||
alt((text_with_properties, quoted_atom, unquoted_atom))(input)
|
let (remaining, children) = delimited(
|
||||||
|
multispace0,
|
||||||
|
separated_list1(multispace1, token),
|
||||||
|
multispace0,
|
||||||
|
)(remaining)?;
|
||||||
|
let (remaining, _) = tag("]")(remaining)?;
|
||||||
|
Ok((remaining, Token::Vector(children)))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
|
fn atom<'s>(input: &'s str) -> Res<&'s str, Token<'s>> {
|
||||||
|
not(peek(one_of(")]")))(input)?;
|
||||||
|
alt((
|
||||||
|
text_with_properties,
|
||||||
|
hash_notation,
|
||||||
|
quoted_atom,
|
||||||
|
unquoted_atom,
|
||||||
|
))(input)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn unquoted_atom<'s>(input: &'s str) -> Res<&'s str, Token<'s>> {
|
fn unquoted_atom<'s>(input: &'s str) -> Res<&'s str, Token<'s>> {
|
||||||
let (remaining, body) = take_till1(|c| match c {
|
let (remaining, body) = take_till1(|c| match c {
|
||||||
' ' | '\t' | '\r' | '\n' | ')' => true,
|
' ' | '\t' | '\r' | '\n' | ')' | ']' => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
})(input)?;
|
})(input)?;
|
||||||
Ok((remaining, Token::Atom(body)))
|
Ok((remaining, Token::Atom(body)))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn quoted_atom<'s>(input: &'s str) -> Res<&'s str, Token<'s>> {
|
fn quoted_atom<'s>(input: &'s str) -> Res<&'s str, Token<'s>> {
|
||||||
let (remaining, _) = tag(r#"""#)(input)?;
|
let (remaining, _) = tag(r#"""#)(input)?;
|
||||||
let (remaining, _) = escaped(
|
let (remaining, _) = escaped(
|
||||||
@@ -182,6 +211,18 @@ fn quoted_atom<'s>(input: &'s str) -> Res<&'s str, Token<'s>> {
|
|||||||
Ok((remaining, Token::Atom(source)))
|
Ok((remaining, Token::Atom(source)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
|
fn hash_notation<'s>(input: &'s str) -> Res<&'s str, Token<'s>> {
|
||||||
|
let (remaining, _) = tag("#<")(input)?;
|
||||||
|
let (remaining, _body) = take_till1(|c| match c {
|
||||||
|
'>' => true,
|
||||||
|
_ => false,
|
||||||
|
})(remaining)?;
|
||||||
|
let (remaining, _) = tag(">")(remaining)?;
|
||||||
|
let source = get_consumed(input, remaining);
|
||||||
|
Ok((remaining, Token::Atom(source)))
|
||||||
|
}
|
||||||
|
|
||||||
fn text_with_properties<'s>(input: &'s str) -> Res<&'s str, Token<'s>> {
|
fn text_with_properties<'s>(input: &'s str) -> Res<&'s str, Token<'s>> {
|
||||||
let (remaining, _) = tag("#(")(input)?;
|
let (remaining, _) = tag("#(")(input)?;
|
||||||
let (remaining, (text, props)) = delimited(
|
let (remaining, (text, props)) = delimited(
|
||||||
@@ -237,6 +278,7 @@ mod tests {
|
|||||||
Token::Atom(_) => false,
|
Token::Atom(_) => false,
|
||||||
Token::List(_) => true,
|
Token::List(_) => true,
|
||||||
Token::TextWithProperties(_) => false,
|
Token::TextWithProperties(_) => false,
|
||||||
|
Token::Vector(_) => false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,6 +291,7 @@ mod tests {
|
|||||||
Token::Atom(_) => false,
|
Token::Atom(_) => false,
|
||||||
Token::List(_) => true,
|
Token::List(_) => true,
|
||||||
Token::TextWithProperties(_) => false,
|
Token::TextWithProperties(_) => false,
|
||||||
|
Token::Vector(_) => false,
|
||||||
});
|
});
|
||||||
let children = match parsed {
|
let children = match parsed {
|
||||||
Token::List(children) => children,
|
Token::List(children) => children,
|
||||||
@@ -308,6 +351,7 @@ mod tests {
|
|||||||
Token::Atom(_) => false,
|
Token::Atom(_) => false,
|
||||||
Token::List(_) => true,
|
Token::List(_) => true,
|
||||||
Token::TextWithProperties(_) => false,
|
Token::TextWithProperties(_) => false,
|
||||||
|
Token::Vector(_) => false,
|
||||||
});
|
});
|
||||||
let children = match parsed {
|
let children = match parsed {
|
||||||
Token::List(children) => children,
|
Token::List(children) => children,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ use crate::error::Res;
|
|||||||
use crate::parser::parser_with_context::parser_with_context;
|
use crate::parser::parser_with_context::parser_with_context;
|
||||||
use crate::parser::StatisticsCookie;
|
use crate::parser::StatisticsCookie;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn statistics_cookie<'r, 's>(
|
pub fn statistics_cookie<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -20,7 +20,7 @@ pub fn statistics_cookie<'r, 's>(
|
|||||||
))(input)
|
))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn percent_statistics_cookie<'r, 's>(
|
pub fn percent_statistics_cookie<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -31,7 +31,7 @@ pub fn percent_statistics_cookie<'r, 's>(
|
|||||||
Ok((remaining, StatisticsCookie { source }))
|
Ok((remaining, StatisticsCookie { source }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn fraction_statistics_cookie<'r, 's>(
|
pub fn fraction_statistics_cookie<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ use crate::parser::util::get_one_before;
|
|||||||
use crate::parser::Subscript;
|
use crate::parser::Subscript;
|
||||||
use crate::parser::Superscript;
|
use crate::parser::Superscript;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn subscript<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Subscript<'s>> {
|
pub fn subscript<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Subscript<'s>> {
|
||||||
// We check for the underscore first before checking the pre-character as a minor optimization to avoid walking up the context tree to find the document root unnecessarily.
|
// We check for the underscore first before checking the pre-character as a minor optimization to avoid walking up the context tree to find the document root unnecessarily.
|
||||||
let (remaining, _) = tag("_")(input)?;
|
let (remaining, _) = tag("_")(input)?;
|
||||||
@@ -39,7 +39,7 @@ pub fn subscript<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s st
|
|||||||
Ok((remaining, Subscript { source }))
|
Ok((remaining, Subscript { source }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn superscript<'r, 's>(
|
pub fn superscript<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -53,7 +53,7 @@ pub fn superscript<'r, 's>(
|
|||||||
Ok((remaining, Superscript { source }))
|
Ok((remaining, Superscript { source }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn pre<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, ()> {
|
fn pre<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, ()> {
|
||||||
let document_root = context.get_document_root().unwrap();
|
let document_root = context.get_document_root().unwrap();
|
||||||
let preceding_character = get_one_before(document_root, input)
|
let preceding_character = get_one_before(document_root, input)
|
||||||
@@ -76,7 +76,7 @@ enum ScriptBody<'s> {
|
|||||||
WithBraces(Vec<Object<'s>>),
|
WithBraces(Vec<Object<'s>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn script_body<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, ScriptBody<'s>> {
|
fn script_body<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, ScriptBody<'s>> {
|
||||||
alt((
|
alt((
|
||||||
map(parser_with_context!(script_asterisk)(context), |body| {
|
map(parser_with_context!(script_asterisk)(context), |body| {
|
||||||
@@ -91,12 +91,12 @@ fn script_body<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str,
|
|||||||
))(input)
|
))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn script_asterisk<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn script_asterisk<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
tag("*")(input)
|
tag("*")(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn script_alphanum<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn script_alphanum<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let (remaining, _sign) = opt(recognize(one_of("+-")))(input)?;
|
let (remaining, _sign) = opt(recognize(one_of("+-")))(input)?;
|
||||||
let (remaining, _script) = many_till(
|
let (remaining, _script) = many_till(
|
||||||
@@ -107,7 +107,7 @@ fn script_alphanum<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s
|
|||||||
Ok((remaining, source))
|
Ok((remaining, source))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn script_alphanum_character<'r, 's>(
|
fn script_alphanum_character<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -117,7 +117,7 @@ fn script_alphanum_character<'r, 's>(
|
|||||||
}))(input)
|
}))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn end_script_alphanum_character<'r, 's>(
|
fn end_script_alphanum_character<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -129,7 +129,7 @@ fn end_script_alphanum_character<'r, 's>(
|
|||||||
Ok((remaining, final_char))
|
Ok((remaining, final_char))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn script_with_braces<'r, 's>(
|
fn script_with_braces<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -156,7 +156,7 @@ fn script_with_braces<'r, 's>(
|
|||||||
Ok((remaining, children))
|
Ok((remaining, children))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn script_with_braces_end<'r, 's>(
|
fn script_with_braces_end<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -190,7 +190,7 @@ fn script_with_braces_end<'r, 's>(
|
|||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn get_bracket_depth<'r, 's>(
|
fn get_bracket_depth<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
) -> Option<&'r SubscriptSuperscriptBrace<'s>> {
|
) -> Option<&'r SubscriptSuperscriptBrace<'s>> {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ use crate::parser::Table;
|
|||||||
/// Parse an org-mode-style table
|
/// Parse an org-mode-style table
|
||||||
///
|
///
|
||||||
/// This is not the table.el style.
|
/// This is not the table.el style.
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn org_mode_table<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Table<'s>> {
|
pub fn org_mode_table<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Table<'s>> {
|
||||||
start_of_line(context, input)?;
|
start_of_line(context, input)?;
|
||||||
peek(tuple((space0, tag("|"))))(input)?;
|
peek(tuple((space0, tag("|"))))(input)?;
|
||||||
@@ -55,13 +55,13 @@ pub fn org_mode_table<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&
|
|||||||
Ok((remaining, Table { source, children }))
|
Ok((remaining, Table { source, children }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn table_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn table_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
start_of_line(context, input)?;
|
start_of_line(context, input)?;
|
||||||
recognize(tuple((space0, not(tag("|")))))(input)
|
recognize(tuple((space0, not(tag("|")))))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn org_mode_table_row<'r, 's>(
|
pub fn org_mode_table_row<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -72,7 +72,7 @@ pub fn org_mode_table_row<'r, 's>(
|
|||||||
))(input)
|
))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn org_mode_table_row_rule<'r, 's>(
|
pub fn org_mode_table_row_rule<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -89,7 +89,7 @@ pub fn org_mode_table_row_rule<'r, 's>(
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn org_mode_table_row_regular<'r, 's>(
|
pub fn org_mode_table_row_regular<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -103,7 +103,7 @@ pub fn org_mode_table_row_regular<'r, 's>(
|
|||||||
Ok((remaining, TableRow { source, children }))
|
Ok((remaining, TableRow { source, children }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn org_mode_table_cell<'r, 's>(
|
pub fn org_mode_table_cell<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -128,7 +128,7 @@ pub fn org_mode_table_cell<'r, 's>(
|
|||||||
Ok((remaining, TableCell { source, children }))
|
Ok((remaining, TableCell { source, children }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn org_mode_table_cell_end<'r, 's>(
|
fn org_mode_table_cell_end<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -136,7 +136,7 @@ fn org_mode_table_cell_end<'r, 's>(
|
|||||||
recognize(tuple((space0, alt((tag("|"), peek(line_ending))))))(input)
|
recognize(tuple((space0, alt((tag("|"), peek(line_ending))))))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn table_cell_set_object<'r, 's>(
|
pub fn table_cell_set_object<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ use crate::parser::util::get_consumed;
|
|||||||
use crate::parser::util::get_one_before;
|
use crate::parser::util::get_one_before;
|
||||||
use crate::parser::Target;
|
use crate::parser::Target;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn target<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Target<'s>> {
|
pub fn target<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Target<'s>> {
|
||||||
let (remaining, _) = tag("<<")(input)?;
|
let (remaining, _) = tag("<<")(input)?;
|
||||||
let (remaining, _) = peek(verify(anychar, |c| {
|
let (remaining, _) = peek(verify(anychar, |c| {
|
||||||
@@ -54,7 +54,7 @@ pub fn target<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str,
|
|||||||
Ok((remaining, Target { source }))
|
Ok((remaining, Target { source }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn target_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn target_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
recognize(one_of("<>\n"))(input)
|
recognize(one_of("<>\n"))(input)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ use nom::combinator::recognize;
|
|||||||
use nom::combinator::verify;
|
use nom::combinator::verify;
|
||||||
use nom::multi::many_till;
|
use nom::multi::many_till;
|
||||||
use nom::sequence::terminated;
|
use nom::sequence::terminated;
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
use tracing::span;
|
use tracing::span;
|
||||||
|
|
||||||
use super::radio_link::RematchObject;
|
use super::radio_link::RematchObject;
|
||||||
@@ -37,7 +38,7 @@ use crate::parser::StrikeThrough;
|
|||||||
use crate::parser::Underline;
|
use crate::parser::Underline;
|
||||||
use crate::parser::Verbatim;
|
use crate::parser::Verbatim;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn text_markup<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Object<'s>> {
|
pub fn text_markup<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Object<'s>> {
|
||||||
alt((
|
alt((
|
||||||
map(parser_with_context!(bold)(context), Object::Bold),
|
map(parser_with_context!(bold)(context), Object::Bold),
|
||||||
@@ -52,7 +53,7 @@ pub fn text_markup<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s
|
|||||||
))(input)
|
))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn bold<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Bold<'s>> {
|
pub fn bold<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Bold<'s>> {
|
||||||
let text_markup_object_specialized = text_markup_object("*");
|
let text_markup_object_specialized = text_markup_object("*");
|
||||||
let (remaining, children) = text_markup_object_specialized(context, input)?;
|
let (remaining, children) = text_markup_object_specialized(context, input)?;
|
||||||
@@ -60,7 +61,7 @@ pub fn bold<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Bo
|
|||||||
Ok((remaining, Bold { source, children }))
|
Ok((remaining, Bold { source, children }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn italic<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Italic<'s>> {
|
pub fn italic<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Italic<'s>> {
|
||||||
let text_markup_object_specialized = text_markup_object("/");
|
let text_markup_object_specialized = text_markup_object("/");
|
||||||
let (remaining, children) = text_markup_object_specialized(context, input)?;
|
let (remaining, children) = text_markup_object_specialized(context, input)?;
|
||||||
@@ -68,7 +69,7 @@ pub fn italic<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str,
|
|||||||
Ok((remaining, Italic { source, children }))
|
Ok((remaining, Italic { source, children }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn underline<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Underline<'s>> {
|
pub fn underline<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Underline<'s>> {
|
||||||
let text_markup_object_specialized = text_markup_object("_");
|
let text_markup_object_specialized = text_markup_object("_");
|
||||||
let (remaining, children) = text_markup_object_specialized(context, input)?;
|
let (remaining, children) = text_markup_object_specialized(context, input)?;
|
||||||
@@ -76,7 +77,7 @@ pub fn underline<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s st
|
|||||||
Ok((remaining, Underline { source, children }))
|
Ok((remaining, Underline { source, children }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn strike_through<'r, 's>(
|
pub fn strike_through<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -87,7 +88,7 @@ pub fn strike_through<'r, 's>(
|
|||||||
Ok((remaining, StrikeThrough { source, children }))
|
Ok((remaining, StrikeThrough { source, children }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn verbatim<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Verbatim<'s>> {
|
pub fn verbatim<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Verbatim<'s>> {
|
||||||
let text_markup_string_specialized = text_markup_string("=");
|
let text_markup_string_specialized = text_markup_string("=");
|
||||||
let (remaining, contents) = text_markup_string_specialized(context, input)?;
|
let (remaining, contents) = text_markup_string_specialized(context, input)?;
|
||||||
@@ -95,7 +96,7 @@ pub fn verbatim<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str
|
|||||||
Ok((remaining, Verbatim { source, contents }))
|
Ok((remaining, Verbatim { source, contents }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn code<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Code<'s>> {
|
pub fn code<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Code<'s>> {
|
||||||
let text_markup_string_specialized = text_markup_string("~");
|
let text_markup_string_specialized = text_markup_string("~");
|
||||||
let (remaining, contents) = text_markup_string_specialized(context, input)?;
|
let (remaining, contents) = text_markup_string_specialized(context, input)?;
|
||||||
@@ -110,7 +111,7 @@ fn text_markup_object(
|
|||||||
move |context: Context, input: &str| _text_markup_object(context, input, marker_symbol.as_str())
|
move |context: Context, input: &str| _text_markup_object(context, input, marker_symbol.as_str())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn _text_markup_object<'r, 's, 'x>(
|
fn _text_markup_object<'r, 's, 'x>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -135,7 +136,9 @@ fn _text_markup_object<'r, 's, 'x>(
|
|||||||
)(remaining)?;
|
)(remaining)?;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
let span = span!(tracing::Level::DEBUG, "Checking parent exit.");
|
let span = span!(tracing::Level::DEBUG, "Checking parent exit.");
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
let _enter = span.enter();
|
let _enter = span.enter();
|
||||||
if exit_matcher_parser(context, remaining).is_ok() {
|
if exit_matcher_parser(context, remaining).is_ok() {
|
||||||
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
||||||
@@ -156,7 +159,7 @@ fn text_markup_string(
|
|||||||
move |context: Context, input: &str| _text_markup_string(context, input, marker_symbol.as_str())
|
move |context: Context, input: &str| _text_markup_string(context, input, marker_symbol.as_str())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn _text_markup_string<'r, 's, 'x>(
|
fn _text_markup_string<'r, 's, 'x>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -181,7 +184,9 @@ fn _text_markup_string<'r, 's, 'x>(
|
|||||||
))(remaining)?;
|
))(remaining)?;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
let span = span!(tracing::Level::DEBUG, "Checking parent exit.");
|
let span = span!(tracing::Level::DEBUG, "Checking parent exit.");
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
let _enter = span.enter();
|
let _enter = span.enter();
|
||||||
if exit_matcher_parser(context, remaining).is_ok() {
|
if exit_matcher_parser(context, remaining).is_ok() {
|
||||||
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
||||||
@@ -195,7 +200,7 @@ fn _text_markup_string<'r, 's, 'x>(
|
|||||||
Ok((remaining, contents))
|
Ok((remaining, contents))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn pre<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, ()> {
|
pub fn pre<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, ()> {
|
||||||
let document_root = context.get_document_root().unwrap();
|
let document_root = context.get_document_root().unwrap();
|
||||||
let preceding_character = get_one_before(document_root, input)
|
let preceding_character = get_one_before(document_root, input)
|
||||||
@@ -215,7 +220,7 @@ pub fn pre<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, ()>
|
|||||||
Ok((input, ()))
|
Ok((input, ()))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn post<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, ()> {
|
pub fn post<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, ()> {
|
||||||
let (remaining, _) = alt((recognize(one_of(" \r\n\t-.,;:!?')}[\">")), line_ending))(input)?;
|
let (remaining, _) = alt((recognize(one_of(" \r\n\t-.,;:!?')}[\">")), line_ending))(input)?;
|
||||||
Ok((remaining, ()))
|
Ok((remaining, ()))
|
||||||
@@ -228,7 +233,7 @@ fn text_markup_end(
|
|||||||
move |context: Context, input: &str| _text_markup_end(context, input, marker_symbol.as_str())
|
move |context: Context, input: &str| _text_markup_end(context, input, marker_symbol.as_str())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn _text_markup_end<'r, 's, 'x>(
|
fn _text_markup_end<'r, 's, 'x>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -244,7 +249,7 @@ fn _text_markup_end<'r, 's, 'x>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'x> RematchObject<'x> for Bold<'x> {
|
impl<'x> RematchObject<'x> for Bold<'x> {
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn rematch_object<'r, 's>(
|
fn rematch_object<'r, 's>(
|
||||||
&'x self,
|
&'x self,
|
||||||
_context: Context<'r, 's>,
|
_context: Context<'r, 's>,
|
||||||
@@ -257,7 +262,7 @@ impl<'x> RematchObject<'x> for Bold<'x> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn _rematch_text_markup_object<'r, 's, 'x>(
|
fn _rematch_text_markup_object<'r, 's, 'x>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -279,7 +284,9 @@ fn _rematch_text_markup_object<'r, 's, 'x>(
|
|||||||
rematch_target(&parser_context, original_match_children, remaining)?;
|
rematch_target(&parser_context, original_match_children, remaining)?;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
let span = span!(tracing::Level::DEBUG, "Checking parent exit.");
|
let span = span!(tracing::Level::DEBUG, "Checking parent exit.");
|
||||||
|
#[cfg(feature = "tracing")]
|
||||||
let _enter = span.enter();
|
let _enter = span.enter();
|
||||||
if exit_matcher_parser(context, remaining).is_ok() {
|
if exit_matcher_parser(context, remaining).is_ok() {
|
||||||
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ use crate::parser::util::exit_matcher_parser;
|
|||||||
use crate::parser::util::get_consumed;
|
use crate::parser::util::get_consumed;
|
||||||
use crate::parser::Timestamp;
|
use crate::parser::Timestamp;
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn timestamp<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Timestamp<'s>> {
|
pub fn timestamp<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Timestamp<'s>> {
|
||||||
// TODO: This would be more efficient if we didn't throw away the parse result of the first half of an active/inactive date range timestamp if the parse fails (as in, the first thing active_date_range_timestamp parses is a active_timestamp but then we throw that away if it doesn't turn out to be a full active_date_range_timestamp despite the active_timestamp parse being completely valid). I am going with the simplest/cleanest approach for the first implementation.
|
// TODO: This would be more efficient if we didn't throw away the parse result of the first half of an active/inactive date range timestamp if the parse fails (as in, the first thing active_date_range_timestamp parses is a active_timestamp but then we throw that away if it doesn't turn out to be a full active_date_range_timestamp despite the active_timestamp parse being completely valid). I am going with the simplest/cleanest approach for the first implementation.
|
||||||
alt((
|
alt((
|
||||||
@@ -37,7 +37,7 @@ pub fn timestamp<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s st
|
|||||||
))(input)
|
))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn diary_timestamp<'r, 's>(
|
fn diary_timestamp<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -51,7 +51,7 @@ fn diary_timestamp<'r, 's>(
|
|||||||
Ok((remaining, Timestamp { source }))
|
Ok((remaining, Timestamp { source }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn sexp<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn sexp<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let parser_context =
|
let parser_context =
|
||||||
context.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
|
context.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||||
@@ -70,12 +70,12 @@ fn sexp<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s st
|
|||||||
Ok((remaining, body))
|
Ok((remaining, body))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn sexp_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn sexp_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
alt((tag(")>"), recognize(one_of(">\n"))))(input)
|
alt((tag(")>"), recognize(one_of(">\n"))))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn active_timestamp<'r, 's>(
|
fn active_timestamp<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -103,7 +103,7 @@ fn active_timestamp<'r, 's>(
|
|||||||
Ok((remaining, Timestamp { source }))
|
Ok((remaining, Timestamp { source }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn inactive_timestamp<'r, 's>(
|
fn inactive_timestamp<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -131,7 +131,7 @@ fn inactive_timestamp<'r, 's>(
|
|||||||
Ok((remaining, Timestamp { source }))
|
Ok((remaining, Timestamp { source }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn active_date_range_timestamp<'r, 's>(
|
fn active_date_range_timestamp<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -147,7 +147,7 @@ fn active_date_range_timestamp<'r, 's>(
|
|||||||
Ok((remaining, Timestamp { source }))
|
Ok((remaining, Timestamp { source }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn active_time_range_timestamp<'r, 's>(
|
fn active_time_range_timestamp<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -182,7 +182,7 @@ fn active_time_range_timestamp<'r, 's>(
|
|||||||
Ok((remaining, Timestamp { source }))
|
Ok((remaining, Timestamp { source }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn inactive_date_range_timestamp<'r, 's>(
|
fn inactive_date_range_timestamp<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -198,7 +198,7 @@ fn inactive_date_range_timestamp<'r, 's>(
|
|||||||
Ok((remaining, Timestamp { source }))
|
Ok((remaining, Timestamp { source }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn inactive_time_range_timestamp<'r, 's>(
|
fn inactive_time_range_timestamp<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -233,7 +233,7 @@ fn inactive_time_range_timestamp<'r, 's>(
|
|||||||
Ok((remaining, Timestamp { source }))
|
Ok((remaining, Timestamp { source }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn date<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn date<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let (remaining, _year) = verify(digit1, |year: &str| year.len() == 4)(input)?;
|
let (remaining, _year) = verify(digit1, |year: &str| year.len() == 4)(input)?;
|
||||||
let (remaining, _) = tag("-")(remaining)?;
|
let (remaining, _) = tag("-")(remaining)?;
|
||||||
@@ -247,7 +247,7 @@ fn date<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s st
|
|||||||
Ok((remaining, source))
|
Ok((remaining, source))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn dayname<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn dayname<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let parser_context =
|
let parser_context =
|
||||||
context.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
|
context.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||||
@@ -266,14 +266,14 @@ fn dayname<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s
|
|||||||
Ok((remaining, body))
|
Ok((remaining, body))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn dayname_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn dayname_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
recognize(verify(anychar, |c| {
|
recognize(verify(anychar, |c| {
|
||||||
c.is_whitespace() || "+-]>0123456789\n".contains(*c)
|
c.is_whitespace() || "+-]>0123456789\n".contains(*c)
|
||||||
}))(input)
|
}))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn time<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn time<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let (remaining, _hour) =
|
let (remaining, _hour) =
|
||||||
verify(digit1, |hour: &str| hour.len() >= 1 && hour.len() <= 2)(input)?;
|
verify(digit1, |hour: &str| hour.len() >= 1 && hour.len() <= 2)(input)?;
|
||||||
@@ -284,7 +284,7 @@ fn time<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s st
|
|||||||
Ok((remaining, source))
|
Ok((remaining, source))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn time_rest<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn time_rest<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
let (remaining, body) = recognize(verify(
|
let (remaining, body) = recognize(verify(
|
||||||
many_till(anychar, parser_with_context!(exit_matcher_parser)(context)),
|
many_till(anychar, parser_with_context!(exit_matcher_parser)(context)),
|
||||||
@@ -294,7 +294,7 @@ fn time_rest<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &
|
|||||||
Ok((remaining, body))
|
Ok((remaining, body))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn active_time_rest_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn active_time_rest_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
alt((
|
alt((
|
||||||
recognize(verify(anychar, |c| ">\n".contains(*c))),
|
recognize(verify(anychar, |c| ">\n".contains(*c))),
|
||||||
@@ -306,7 +306,7 @@ fn active_time_rest_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res
|
|||||||
))(input)
|
))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn inactive_time_rest_end<'r, 's>(
|
fn inactive_time_rest_end<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -321,7 +321,7 @@ fn inactive_time_rest_end<'r, 's>(
|
|||||||
))(input)
|
))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn time_range_rest_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn time_range_rest_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
// We pop off the most recent context element to get a context tree with just the active/inactive_time_rest_end exit matcher (removing this function from the exit matcher chain) because the 2nd time in the range does not end when a "-TIME" pattern is found.
|
// We pop off the most recent context element to get a context tree with just the active/inactive_time_rest_end exit matcher (removing this function from the exit matcher chain) because the 2nd time in the range does not end when a "-TIME" pattern is found.
|
||||||
let parent_node = context.iter().next().expect("Two context elements are added to the tree when adding this exit matcher, so it should be impossible for this to return None.");
|
let parent_node = context.iter().next().expect("Two context elements are added to the tree when adding this exit matcher, so it should be impossible for this to return None.");
|
||||||
@@ -331,7 +331,7 @@ fn time_range_rest_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<
|
|||||||
exit_contents
|
exit_contents
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn repeater<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn repeater<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
// + for cumulative type
|
// + for cumulative type
|
||||||
// ++ for catch-up type
|
// ++ for catch-up type
|
||||||
@@ -344,7 +344,7 @@ fn repeater<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'
|
|||||||
Ok((remaining, source))
|
Ok((remaining, source))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn warning_delay<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
fn warning_delay<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
// - for all type
|
// - for all type
|
||||||
// -- for first type
|
// -- for first type
|
||||||
|
|||||||
@@ -107,13 +107,13 @@ pub fn get_consumed<'s>(input: &'s str, remaining: &'s str) -> &'s str {
|
|||||||
/// A line containing only whitespace and then a line break
|
/// A line containing only whitespace and then a line break
|
||||||
///
|
///
|
||||||
/// It is up to the caller to ensure this is called at the start of a line.
|
/// It is up to the caller to ensure this is called at the start of a line.
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn blank_line(input: &str) -> Res<&str, &str> {
|
pub fn blank_line(input: &str) -> Res<&str, &str> {
|
||||||
not(eof)(input)?;
|
not(eof)(input)?;
|
||||||
recognize(tuple((space0, alt((line_ending, eof)))))(input)
|
recognize(tuple((space0, alt((line_ending, eof)))))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn element_trailing_whitespace<'r, 's>(
|
pub fn element_trailing_whitespace<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -122,7 +122,7 @@ pub fn element_trailing_whitespace<'r, 's>(
|
|||||||
alt((eof, recognize(many0(blank_line))))(input)
|
alt((eof, recognize(many0(blank_line))))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn maybe_consume_trailing_whitespace_if_not_exiting<'r, 's>(
|
pub fn maybe_consume_trailing_whitespace_if_not_exiting<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -137,7 +137,7 @@ pub fn maybe_consume_trailing_whitespace_if_not_exiting<'r, 's>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn maybe_consume_trailing_whitespace<'r, 's>(
|
pub fn maybe_consume_trailing_whitespace<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -151,13 +151,13 @@ pub fn maybe_consume_trailing_whitespace<'r, 's>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn trailing_whitespace(input: &str) -> Res<&str, &str> {
|
pub fn trailing_whitespace(input: &str) -> Res<&str, &str> {
|
||||||
alt((eof, recognize(tuple((line_ending, many0(blank_line))))))(input)
|
alt((eof, recognize(tuple((line_ending, many0(blank_line))))))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check that we are at the start of a line
|
/// Check that we are at the start of a line
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn start_of_line<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, ()> {
|
pub fn start_of_line<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, ()> {
|
||||||
let document_root = context.get_document_root().unwrap();
|
let document_root = context.get_document_root().unwrap();
|
||||||
let preceding_character = get_one_before(document_root, input)
|
let preceding_character = get_one_before(document_root, input)
|
||||||
@@ -178,7 +178,7 @@ pub fn start_of_line<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Check that we are at the start of a line
|
/// Check that we are at the start of a line
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn preceded_by_whitespace<'r, 's>(
|
pub fn preceded_by_whitespace<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -202,13 +202,13 @@ pub fn preceded_by_whitespace<'r, 's>(
|
|||||||
/// Pull one non-whitespace character.
|
/// Pull one non-whitespace character.
|
||||||
///
|
///
|
||||||
/// This function only operates on spaces, tabs, carriage returns, and line feeds. It does not handle fancy unicode whitespace.
|
/// This function only operates on spaces, tabs, carriage returns, and line feeds. It does not handle fancy unicode whitespace.
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn non_whitespace_character(input: &str) -> Res<&str, char> {
|
pub fn non_whitespace_character(input: &str) -> Res<&str, char> {
|
||||||
none_of(" \t\r\n")(input)
|
none_of(" \t\r\n")(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check that we are at the start of a line
|
/// Check that we are at the start of a line
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn exit_matcher_parser<'r, 's>(
|
pub fn exit_matcher_parser<'r, 's>(
|
||||||
context: Context<'r, 's>,
|
context: Context<'r, 's>,
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@@ -216,19 +216,19 @@ pub fn exit_matcher_parser<'r, 's>(
|
|||||||
peek(|i| context.check_exit_matcher(i))(input)
|
peek(|i| context.check_exit_matcher(i))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn always_fail<'r, 's>(_context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
pub fn always_fail<'r, 's>(_context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
Err(nom::Err::Error(CustomError::MyError(MyError(
|
Err(nom::Err::Error(CustomError::MyError(MyError(
|
||||||
"Always fail",
|
"Always fail",
|
||||||
))))
|
))))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn whitespace_eof(input: &str) -> Res<&str, &str> {
|
pub fn whitespace_eof(input: &str) -> Res<&str, &str> {
|
||||||
recognize(tuple((multispace0, eof)))(input)
|
recognize(tuple((multispace0, eof)))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(ret, level = "debug")]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn text_until_exit<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
pub fn text_until_exit<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||||
recognize(verify(
|
recognize(verify(
|
||||||
many_till(anychar, parser_with_context!(exit_matcher_parser)(context)),
|
many_till(anychar, parser_with_context!(exit_matcher_parser)(context)),
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
foo bar baz
|
|
||||||
|
|
||||||
lorem ipsum
|
|
||||||
Reference in New Issue
Block a user