Compare commits

..

1 Commits

Author SHA1 Message Date
Davis Davalos-DeLosh
2a7a489c23
Optionally preserve modified time of exported files
Add a new argument --preserve-mtime to keep the original modified time
attribute of notes being exported, instead of setting them to the
current time.
2024-08-04 13:57:27 +02:00
26 changed files with 193 additions and 381 deletions

View File

@ -4,7 +4,6 @@
"schedule:monthly",
// Group updates to linters together in one PR
"group:linters",
":semanticCommitsDisabled"
],
dependencyDashboard: true,
"labels": ["dependencies"],
@ -23,19 +22,6 @@
"packageNameTemplate": "rust-lang/rust",
"datasourceTemplate": "github-releases"
},
{
"customType": "regex",
"fileMatch": ["^Justfile$"],
"matchStrings": [
// https://regex101.com/r/vOmY6R/1
// Matching on word boundaries (\b) around start and end ensures we
// match variations like "towncrier==1.2.3" as well as "pipx run
// towncrier==1.2.3", adding some future proofness.
"\".*\\btowncrier==(?<currentValue>.+?)\\b\""
],
"depNameTemplate": "towncrier",
"datasourceTemplate": "pypi"
},
],
packageRules: [
{
@ -43,21 +29,6 @@
minimumReleaseAge: "3 days",
automerge: true
},
{
// pulldown-cmark and pulldown-cmark-to-mark must be updated in
// lockstep in case of breaking changes, so it's best to group them
// together.
"matchPackageNames": ["pulldown-cmark*"],
// pulldown-cmark is currently on a 0.x release series while
// pulldown-cmark-to-cmark tends to bump the major version
// component whenever pulldown-cmark creates a new release (which
// increments the minor component). Renovate by default creates
// separate PRs for major and minor bumps which fails to match up
// with the grouping. Disabling this behavior ensures that both
// packages are always updated together in a single PR.
"separateMajorMinor": false,
"groupName": "pulldown-cmark (group)"
},
],
ignorePaths: [
// Auto-generated by cargo-dist (https://opensource.axo.dev/cargo-dist/)

View File

@ -15,5 +15,5 @@ jobs:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: ./.github/actions/setup-ci
- uses: dtolnay/rust-toolchain@stable
- run: cargo publish

View File

@ -30,3 +30,8 @@ repos:
language: system
files: \.rs$
pass_filenames: false
- id: README
name: Render README.md
entry: docs/generate.sh
language: script
files: ^(README\.md)|(docs/.*)

View File

@ -1,7 +1,5 @@
# Changelog
<!-- towncrier release notes start -->
## v23.12.0 (2023-12-03)
### New

View File

@ -74,9 +74,4 @@ If you don't feel comfortable writing user documentation, I will be happy to gui
> **⚠ Warning**
>
> If you update the README file, take note that you must edit the fragments in the [docs](docs/) directory as opposed to the README in the root of the repository, which is auto-generated with every release.
## Release notes
[Towncrier](https://towncrier.readthedocs.io/en/stable/index.html) is used to generate release notes.
If you add a changelog fragment to the `changelog.d` directory with `just add-changelog` (requires [just](https://github.com/casey/just#installation)) it will automatically be picked up when a new release is made.
> If you update the README file, take note that you must edit the fragments in the [docs](docs/) directory as opposed to the README in the root of the repository, which is auto-generated.

157
Cargo.lock generated
View File

@ -17,6 +17,12 @@ version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitflags"
version = "2.6.0"
@ -101,7 +107,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba"
dependencies = [
"libc",
"windows-sys 0.52.0",
"windows-sys",
]
[[package]]
@ -116,20 +122,20 @@ dependencies = [
[[package]]
name = "fastrand"
version = "2.1.1"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6"
checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a"
[[package]]
name = "filetime"
version = "0.2.24"
version = "0.2.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf401df4a4e3872c4fe8151134cf483738e74b67fc934d6532c882b3d24a4550"
checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd"
dependencies = [
"cfg-if",
"libc",
"libredox",
"windows-sys 0.59.0",
"redox_syscall",
"windows-sys",
]
[[package]]
@ -188,7 +194,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.76",
"syn 2.0.72",
]
[[package]]
@ -311,9 +317,9 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683"
[[package]]
name = "indexmap"
version = "2.4.0"
version = "2.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c"
checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26"
dependencies = [
"equivalent",
"hashbrown",
@ -326,21 +332,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
[[package]]
name = "libc"
version = "0.2.158"
name = "lazy_static"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439"
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
[[package]]
name = "libredox"
version = "0.1.3"
name = "libc"
version = "0.2.155"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d"
dependencies = [
"bitflags",
"libc",
"redox_syscall",
]
checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
[[package]]
name = "linux-raw-sys"
@ -354,6 +355,16 @@ version = "0.4.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
[[package]]
name = "matter"
version = "0.1.0-alpha4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc16e839c57e0ad77957c42d39baab3692a1c6fa47692066470cddc24a5b0cd0"
dependencies = [
"lazy_static",
"regex",
]
[[package]]
name = "memchr"
version = "2.7.4"
@ -368,6 +379,7 @@ dependencies = [
"filetime",
"gumdrop",
"ignore",
"matter",
"pathdiff",
"percent-encoding",
"pretty_assertions",
@ -444,37 +456,30 @@ dependencies = [
[[package]]
name = "pulldown-cmark"
version = "0.12.0"
version = "0.9.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d31cbfcd94884c3a67ec210c83efb06cb43674043458b0ad59f6947f8462c23"
checksum = "57206b407293d2bcd3af849ce869d52068623f19e1b5ff8e8778e3309439682b"
dependencies = [
"bitflags",
"bitflags 2.6.0",
"getopts",
"memchr",
"pulldown-cmark-escape",
"unicase",
]
[[package]]
name = "pulldown-cmark-escape"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "007d8adb5ddab6f8e3f491ac63566a7d5002cc7ed73901f72057943fa71ae1ae"
[[package]]
name = "pulldown-cmark-to-cmark"
version = "16.0.1"
version = "11.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "171b9687038fb417937aee4ce1d0a269897091f05be16660a1e45777533c54b9"
checksum = "6dd464f32d7631035e849fcd969a603e9bb17ceaebe8467352a7728147f34e42"
dependencies = [
"pulldown-cmark",
]
[[package]]
name = "quote"
version = "1.0.37"
version = "1.0.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
dependencies = [
"proc-macro2",
]
@ -501,11 +506,11 @@ dependencies = [
[[package]]
name = "redox_syscall"
version = "0.5.3"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4"
checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa"
dependencies = [
"bitflags",
"bitflags 1.3.2",
]
[[package]]
@ -569,7 +574,7 @@ dependencies = [
"regex",
"relative-path",
"rustc_version",
"syn 2.0.76",
"syn 2.0.72",
"unicode-ident",
]
@ -588,11 +593,11 @@ version = "0.38.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f"
dependencies = [
"bitflags",
"bitflags 2.6.0",
"errno",
"libc",
"linux-raw-sys",
"windows-sys 0.52.0",
"windows-sys",
]
[[package]]
@ -618,22 +623,22 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b"
[[package]]
name = "serde"
version = "1.0.209"
version = "1.0.204"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09"
checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.209"
version = "1.0.204"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170"
checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.76",
"syn 2.0.72",
]
[[package]]
@ -660,9 +665,9 @@ dependencies = [
[[package]]
name = "slug"
version = "0.1.6"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "882a80f72ee45de3cc9a5afeb2da0331d58df69e4e7d8eeb5d3c7784ae67e724"
checksum = "3bd94acec9c8da640005f8e135a39fc0372e74535e6b368b7a04b875f784c8c4"
dependencies = [
"deunicode",
"wasm-bindgen",
@ -686,7 +691,7 @@ dependencies = [
"heck",
"proc-macro2",
"quote",
"syn 2.0.76",
"syn 2.0.72",
]
[[package]]
@ -702,9 +707,9 @@ dependencies = [
[[package]]
name = "syn"
version = "2.0.76"
version = "2.0.72"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "578e081a14e0cefc3279b0472138c513f37b41a08d5a3cca9b6e4e8ceb6cd525"
checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af"
dependencies = [
"proc-macro2",
"quote",
@ -713,15 +718,15 @@ dependencies = [
[[package]]
name = "tempfile"
version = "3.12.0"
version = "3.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64"
checksum = "b8fcd239983515c23a32fb82099f97d0b11b8c72f654ed659363a95c3dad7a53"
dependencies = [
"cfg-if",
"fastrand",
"once_cell",
"rustix",
"windows-sys 0.59.0",
"windows-sys",
]
[[package]]
@ -741,9 +746,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "toml_datetime"
version = "0.6.8"
version = "0.6.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41"
checksum = "f8fb9f64314842840f1d940ac544da178732128f1c78c21772e876579e0da1db"
[[package]]
name = "toml_edit"
@ -810,35 +815,34 @@ dependencies = [
[[package]]
name = "wasm-bindgen"
version = "0.2.93"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5"
checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8"
dependencies = [
"cfg-if",
"once_cell",
"wasm-bindgen-macro",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.93"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b"
checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da"
dependencies = [
"bumpalo",
"log",
"once_cell",
"proc-macro2",
"quote",
"syn 2.0.76",
"syn 2.0.72",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.93"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf"
checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
@ -846,30 +850,30 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.93"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836"
checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.76",
"syn 2.0.72",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.93"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484"
checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96"
[[package]]
name = "winapi-util"
version = "0.1.9"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b"
dependencies = [
"windows-sys 0.59.0",
"windows-sys",
]
[[package]]
@ -881,15 +885,6 @@ dependencies = [
"windows-targets",
]
[[package]]
name = "windows-sys"
version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-targets"
version = "0.52.6"

View File

@ -28,10 +28,11 @@ doc = false
eyre = "0.6.12"
gumdrop = "0.8.1"
ignore = "0.4.22"
matter = "0.1.0-alpha4"
pathdiff = "0.2.1"
percent-encoding = "2.3.1"
pulldown-cmark = "0.12.0"
pulldown-cmark-to-cmark = "16.0.0"
pulldown-cmark = "0.9.3"
pulldown-cmark-to-cmark = "11.0.2"
rayon = "1.10.0"
regex = "1.10.5"
serde_yaml = "0.9.34"

View File

@ -1,67 +0,0 @@
towncrier_cmd := "pipx run towncrier==24.8.0"
_default:
@{{just_executable()}} --choose
# Add a new changelog entry using towncrier
add-changelog:
{{towncrier_cmd}} create --edit
git add changelog.d
# Create a new release
make-new-release:
#!/usr/bin/env bash
set -euo pipefail
get_next_version_number() {
DATEPART=$(date +%y.%-m)
ITERATION=0
while true; do
VERSION_STRING="${DATEPART}.${ITERATION}"
if git rev-list "v$VERSION_STRING" > /dev/null 2>&1; then
((ITERATION++))
else
echo "$VERSION_STRING"
return
fi
done
}
git add .
if ! git diff-index --quiet HEAD; then
printf "Working directory is not clean. Please commit or stash your changes.\n"
exit 1
fi
VERSION=$(get_next_version_number)
COMMITMSG=$(mktemp --tmpdir commitmsg.XXXXXXXXXX)
trap 'rm "$COMMITMSG"' EXIT
set -x
cargo set-version "${VERSION}"
# Construct a git commit message.
# This must be done before the next step so we can leverage the --draft
# flag here to get a list of changes being introduced by this release.
printf "Release v${VERSION}\n\n" > "$COMMITMSG"
{{towncrier_cmd}} build --draft --version "${VERSION}" >> "$COMMITMSG"
# Generate changelog and docs
{{towncrier_cmd}} build --version "${VERSION}"
docs/generate.sh
# Stage all the changes we've prepared
git add .
# There are likely trailing whitespace changes in the changelog, but a single
# run of pre-commit will fix these automatically.
pre-commit run || git add .
git commit --file "$COMMITMSG"
git tag "v${VERSION}"
set +x
printf "\n\nSuccessfully created release %s\n" "v${VERSION}"
printf "\nYou'll probably want to continue with:\n"
printf "\tgit push origin main\n"
printf "\tgit push origin %s\n" "v${VERSION}"

View File

@ -1,4 +0,0 @@
Bump to the minimum supported Rust version to 1.80.0
Obsidian-export now uses [std::sync::LazyLock](https://doc.rust-lang.org/std/sync/struct.LazyLock.html) instead of [lazy_static](https://crates.io/crates/lazy_static), which was only stabilized in Rust 1.80.0.
This change made it possible to drop the external dependency on lazy_static, though as a result of this, compiling with older versions will no longer be possible.

View File

View File

@ -1 +0,0 @@
252.breaking.md

View File

@ -1,4 +0,0 @@
Don't escape square brackets in math expressions
The upgrade to [pulldown-cmark](https://crates.io/crates/pulldown-cmark) 0.11 (see Backwards-incompatible Changes) includes official support for LaTeX-style math expressions.
With the markdown parser supporting this syntax natively, math expressions are now processed correctly without edge-cases.

View File

@ -1 +0,0 @@
204.new.md

View File

@ -1,5 +0,0 @@
Optionally preserve modified time of exported files
Add a new argument `--preserve-mtime` to keep the original modified time attribute of notes being exported, instead of setting them to the current time.
Contribution made by [Davis Davalos-DeLosh](https://github.com/Programmerino).

View File

@ -1,12 +0,0 @@
Upgrade [pulldown-cmark](https://crates.io/crates/pulldown-cmark) from 0.9 to 0.12
pulldown-cmark is the Markdown/CommonMark parser that is used to read and convert notes (together with [pulldown-cmark-to-cmark](https://crates.io/crates/pulldown-cmark-to-cmark)).
For end-users that call the obsidian-export CLI this upgrade will be mostly transparent, except that Math blocks are now properly processed without getting mangled.
People who use the library directly may face more significant breaking changes if they have custom postprocessors, as pulldown-cmark's events have gone through various breaking changes.
For more information, see:
- <https://github.com/zoni/obsidian-export/pull/252>
- <https://github.com/pulldown-cmark/pulldown-cmark/releases/tag/v0.10.0>
- <https://github.com/zoni/obsidian-export/pull/276/files#diff-b1a35a68f14e696205874893c07fd24fdb88882b47c23cc0e0c80a30c7d53759>

View File

@ -1 +0,0 @@
14.fix.md

View File

@ -1 +0,0 @@
252.breaking.md

View File

@ -1 +0,0 @@
252.breaking.md

View File

@ -62,6 +62,12 @@ skip = [
# result. We can then choose to again skip that version, or decide more
# drastic action is needed.
"syn:<=1.0.109",
# filetime depends on redox_syscall which depends on bitflags 1.x, whereas
# other dependencies in our tree depends on bitflags 2.x. This should solve
# itself when a new release is made for filetime, as redox_syscall is
# deprecated and already replaced by libredox anyway
# (https://github.com/alexcrichton/filetime/pull/103)
"bitflags:<=1.3.2",
]
wildcards = "deny"
allow-wildcard-paths = false

View File

@ -1,5 +1,5 @@
# Release process
- [ ] Run `just make-new-release`
- [ ] Run `./make-new-release.sh`
- [ ] Push the created release commit/tag to GitHub
- [ ] Wait for builds to turn green (<https://github.com/zoni/obsidian-export/actions>) and confirm everything looks OK.

47
make-new-release.sh Executable file
View File

@ -0,0 +1,47 @@
#!/usr/bin/env bash
set -euo pipefail
get_next_version_number() {
DATEPART=$(date +%y.%-m)
ITERATION=0
while true; do
VERSION_STRING="${DATEPART}.${ITERATION}"
if git rev-list "v$VERSION_STRING" > /dev/null 2>&1; then
((ITERATION++))
else
echo "$VERSION_STRING"
return
fi
done
}
git add .
if ! git diff-index --quiet HEAD; then
printf "Working directory is not clean. Please commit or stash your changes.\n"
exit 1
fi
VERSION=$(get_next_version_number)
git tag "v${VERSION}"
git cliff --latest --prepend CHANGELOG.md > /dev/null
${EDITOR:-vim} CHANGELOG.md
docs/generate.sh
sed -i -E "s/^version = \".+\"$/version = \"${VERSION}\"/" Cargo.toml
cargo check
git add .
# There are likely trailing whitespace changes in the changelog, but a single
# run of pre-commit will fix these automatically.
pre-commit run || git add .
git commit --message "Release v${VERSION}"
git tag "v${VERSION}" --force
printf "\n\nSuccessfully created release %s\n" "v${VERSION}"
printf "\nYou'll probably want to continue with:\n"
printf "\tgit push origin main\n"
printf "\tgit push origin %s\n" "v${VERSION}"

View File

@ -19,7 +19,7 @@ use frontmatter::{frontmatter_from_str, frontmatter_to_str};
pub use frontmatter::{Frontmatter, FrontmatterStrategy};
use pathdiff::diff_paths;
use percent_encoding::{utf8_percent_encode, AsciiSet, CONTROLS};
use pulldown_cmark::{CodeBlockKind, CowStr, Event, HeadingLevel, Options, Parser, Tag, TagEnd};
use pulldown_cmark::{CodeBlockKind, CowStr, Event, HeadingLevel, Options, Parser, Tag};
use pulldown_cmark_to_cmark::cmark_with_options;
use rayon::prelude::*;
use references::{ObsidianNoteReference, RefParser, RefParserState, RefType};
@ -467,7 +467,6 @@ impl<'a> Exporter<'a> {
#[allow(clippy::too_many_lines)]
#[allow(clippy::panic_in_result_fn)]
#[allow(clippy::shadow_unrelated)]
fn parse_obsidian_note<'b>(
&self,
path: &Path,
@ -479,40 +478,23 @@ impl<'a> Exporter<'a> {
});
}
let content = fs::read_to_string(path).context(ReadSnafu { path })?;
let mut frontmatter = String::new();
let (frontmatter, content) =
matter::matter(&content).unwrap_or((String::new(), content.clone()));
let frontmatter =
frontmatter_from_str(&frontmatter).context(FrontMatterDecodeSnafu { path })?;
let parser_options = Options::ENABLE_TABLES
| Options::ENABLE_FOOTNOTES
| Options::ENABLE_STRIKETHROUGH
| Options::ENABLE_TASKLISTS
| Options::ENABLE_MATH
| Options::ENABLE_YAML_STYLE_METADATA_BLOCKS;
let mut parser_options = Options::empty();
parser_options.insert(Options::ENABLE_TABLES);
parser_options.insert(Options::ENABLE_FOOTNOTES);
parser_options.insert(Options::ENABLE_STRIKETHROUGH);
parser_options.insert(Options::ENABLE_TASKLISTS);
let mut ref_parser = RefParser::new();
let mut events = vec![];
// Most of the time, a reference triggers 5 events: [ or ![, [, <text>, ], ]
let mut buffer = Vec::with_capacity(5);
let mut parser = Parser::new_ext(&content, parser_options);
'outer: while let Some(event) = parser.next() {
// When encountering a metadata block (frontmatter), collect all events until getting
// to the end of the block, at which point the nested loop will break out to the outer
// loop again.
if matches!(event, Event::Start(Tag::MetadataBlock(_kind))) {
for event in parser.by_ref() {
match event {
Event::Text(cowstr) => frontmatter.push_str(&cowstr),
Event::End(TagEnd::MetadataBlock(_kind)) => {
continue 'outer;
},
_ => panic!(
"Encountered an unexpected event while processing frontmatter in {}. Please report this as a bug with a copy of the note contents and this text: \n\nEvent: {:?}\n",
path.display(),
event
),
}
}
}
for event in Parser::new_ext(&content, parser_options) {
if ref_parser.state == RefParserState::Resetting {
events.append(&mut buffer);
buffer.clear();
@ -601,9 +583,8 @@ impl<'a> Exporter<'a> {
if !buffer.is_empty() {
events.append(&mut buffer);
}
Ok((
frontmatter_from_str(&frontmatter).context(FrontMatterDecodeSnafu { path })?,
frontmatter,
events.into_iter().map(event_to_owned).collect(),
))
}
@ -681,18 +662,20 @@ impl<'a> Exporter<'a> {
// into an image reference instead. Slightly hacky, but avoids needing
// to keep another utility function around for this, or introducing an
// extra parameter on make_link_to_file.
Event::Start(Tag::Link {
link_type,
dest_url,
title,
id,
}) => Event::Start(Tag::Image {
link_type,
dest_url: CowStr::from(dest_url.into_string()),
title: CowStr::from(title.into_string()),
id: CowStr::from(id.into_string()),
}),
Event::End(TagEnd::Link) => Event::End(TagEnd::Image),
Event::Start(Tag::Link(linktype, cowstr1, cowstr2)) => {
Event::Start(Tag::Image(
linktype,
CowStr::from(cowstr1.into_string()),
CowStr::from(cowstr2.into_string()),
))
}
Event::End(Tag::Link(linktype, cowstr1, cowstr2)) => {
Event::End(Tag::Image(
linktype,
CowStr::from(cowstr1.into_string()),
CowStr::from(cowstr2.into_string()),
))
}
_ => event,
})
.collect()
@ -724,7 +707,7 @@ impl<'a> Exporter<'a> {
return vec![
Event::Start(Tag::Emphasis),
Event::Text(CowStr::from(reference.display())),
Event::End(TagEnd::Emphasis),
Event::End(Tag::Emphasis),
];
}
let target_file = target_file.unwrap();
@ -748,17 +731,16 @@ impl<'a> Exporter<'a> {
link.push_str(&slugify(section));
}
let link_tag = Tag::Link {
link_type: pulldown_cmark::LinkType::Inline,
dest_url: CowStr::from(link),
title: CowStr::from(""),
id: CowStr::from(""),
};
let link_tag = Tag::Link(
pulldown_cmark::LinkType::Inline,
CowStr::from(link),
CowStr::from(""),
);
vec![
Event::Start(link_tag),
Event::Start(link_tag.clone()),
Event::Text(CowStr::from(reference.display())),
Event::End(TagEnd::Link),
Event::End(link_tag.clone()),
]
}
}
@ -859,7 +841,8 @@ fn reduce_to_section<'a>(events: MarkdownEvents<'a>, section: &str) -> MarkdownE
for event in events {
filtered_events.push(event.clone());
match event {
Event::Start(Tag::Heading { level, .. }) => {
// FIXME: This should propagate fragment_identifier and classes.
Event::Start(Tag::Heading(level, _fragment_identifier, _classes)) => {
last_tag_was_heading = true;
last_level = level;
if currently_in_target_section && level <= section_level {
@ -898,11 +881,10 @@ fn reduce_to_section<'a>(events: MarkdownEvents<'a>, section: &str) -> MarkdownE
fn event_to_owned<'a>(event: Event<'_>) -> Event<'a> {
match event {
Event::Start(tag) => Event::Start(tag_to_owned(tag)),
Event::End(tag) => Event::End(tag),
Event::End(tag) => Event::End(tag_to_owned(tag)),
Event::Text(cowstr) => Event::Text(CowStr::from(cowstr.into_string())),
Event::Code(cowstr) => Event::Code(CowStr::from(cowstr.into_string())),
Event::Html(cowstr) => Event::Html(CowStr::from(cowstr.into_string())),
Event::InlineHtml(cowstr) => Event::InlineHtml(CowStr::from(cowstr.into_string())),
Event::FootnoteReference(cowstr) => {
Event::FootnoteReference(CowStr::from(cowstr.into_string()))
}
@ -910,37 +892,17 @@ fn event_to_owned<'a>(event: Event<'_>) -> Event<'a> {
Event::HardBreak => Event::HardBreak,
Event::Rule => Event::Rule,
Event::TaskListMarker(checked) => Event::TaskListMarker(checked),
Event::InlineMath(cowstr) => Event::InlineMath(CowStr::from(cowstr.into_string())),
Event::DisplayMath(cowstr) => Event::DisplayMath(CowStr::from(cowstr.into_string())),
}
}
fn tag_to_owned<'a>(tag: Tag<'_>) -> Tag<'a> {
match tag {
Tag::Paragraph => Tag::Paragraph,
Tag::Heading {
level: heading_level,
id,
classes,
attrs,
} => Tag::Heading {
level: heading_level,
id: id.map(|cowstr| CowStr::from(cowstr.into_string())),
classes: classes
.into_iter()
.map(|cowstr| CowStr::from(cowstr.into_string()))
.collect(),
attrs: attrs
.into_iter()
.map(|(attr, value)| {
(
CowStr::from(attr.into_string()),
value.map(|cowstr| CowStr::from(cowstr.into_string())),
)
})
.collect(),
},
Tag::BlockQuote(blockquote_kind) => Tag::BlockQuote(blockquote_kind),
Tag::Heading(level, _fragment_identifier, _classes) => {
// FIXME: This should propagate fragment_identifier and classes.
Tag::Heading(level, None, Vec::new())
}
Tag::BlockQuote => Tag::BlockQuote,
Tag::CodeBlock(codeblock_kind) => Tag::CodeBlock(codeblock_kind_to_owned(codeblock_kind)),
Tag::List(optional) => Tag::List(optional),
Tag::Item => Tag::Item,
@ -954,33 +916,16 @@ fn tag_to_owned<'a>(tag: Tag<'_>) -> Tag<'a> {
Tag::Emphasis => Tag::Emphasis,
Tag::Strong => Tag::Strong,
Tag::Strikethrough => Tag::Strikethrough,
Tag::Link {
link_type,
dest_url,
title,
id,
} => Tag::Link {
link_type,
dest_url: CowStr::from(dest_url.into_string()),
title: CowStr::from(title.into_string()),
id: CowStr::from(id.into_string()),
},
Tag::Image {
link_type,
dest_url,
title,
id,
} => Tag::Image {
link_type,
dest_url: CowStr::from(dest_url.into_string()),
title: CowStr::from(title.into_string()),
id: CowStr::from(id.into_string()),
},
Tag::HtmlBlock => Tag::HtmlBlock,
Tag::MetadataBlock(metadata_block_kind) => Tag::MetadataBlock(metadata_block_kind),
Tag::DefinitionList => Tag::DefinitionList,
Tag::DefinitionListTitle => Tag::DefinitionListTitle,
Tag::DefinitionListDefinition => Tag::DefinitionListDefinition,
Tag::Link(linktype, cowstr1, cowstr2) => Tag::Link(
linktype,
CowStr::from(cowstr1.into_string()),
CowStr::from(cowstr2.into_string()),
),
Tag::Image(linktype, cowstr1, cowstr2) => Tag::Image(
linktype,
CowStr::from(cowstr1.into_string()),
CowStr::from(cowstr2.into_string()),
),
}
}

View File

@ -1,11 +0,0 @@
This sentence uses `$` delimiters to show math inline: $\sqrt{3x-1}+(1+x)^2$
This is the same math expression expressed as a block element:
$$\sqrt{3x-1}+(1+x)^2$$
<!-- https://github.com/zoni/obsidian-export/issues/14 -->
With square brackets (inline): $[0, 2\pi]$
With square brackets (block):
$$[0, 2\pi]$$

View File

@ -37,7 +37,7 @@
~~Strikethrough~~
|Table||
|-----|-|
|-----|--|
|Foo|Bar|
[link text](link-location.md)

View File

@ -1,10 +0,0 @@
This sentence uses `$` delimiters to show math inline: $\sqrt{3x-1}+(1+x)^2$
This is the same math expression expressed as a block element:
$$\sqrt{3x-1}+(1+x)^2$$
<!-- https://github.com/zoni/obsidian-export/issues/14 -->
With square brackets (inline): $[0, 2\pi]$
With square brackets (block):
$$[0, 2\pi]$$

View File

@ -1,33 +0,0 @@
[tool.towncrier]
name = "obsidian-export"
directory = "changelog.d"
filename = "CHANGELOG.md"
start_string = "<!-- towncrier release notes start -->\n"
underlines = ["", "", ""]
title_format = "## [{version}](https://github.com/zoni/obsidian-export/tree/{version}) - {project_date}"
issue_format = "[#{issue}](https://github.com/zoni/obsidian-export/issues/{issue})"
[[tool.towncrier.type]]
directory = "new"
name = "New Features"
showcontent = true
[[tool.towncrier.type]]
directory = "change"
name = "Changes"
showcontent = true
[[tool.towncrier.type]]
directory = "fix"
name = "Fixes"
showcontent = true
[[tool.towncrier.type]]
directory = "breaking"
name = "Backwards-incompatible Changes"
showcontent = true
[[tool.towncrier.type]]
directory = "deprecation"
name = "Deprecations"
showcontent = true