Merge pull request #158 from serokell/Sorokin-Anton/#155-footnotes-support

[#155] Footnote syntax support
This commit is contained in:
Sorokin-Anton 2022-09-26 12:22:50 +03:00 committed by GitHub
commit 3ee7649889
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 87 additions and 18 deletions

View File

@ -9,6 +9,9 @@ Unreleased
* [#145](https://github.com/serokell/xrefcheck/pull/145)
+ Add check that there is no unknown fields in config.
* [#158](https://github.com/serokell/xrefcheck/pull/158)
+ Fixed bug when we reported footnotes as broken links
0.2.1
==========

View File

@ -20,7 +20,7 @@ module Xrefcheck.Scanners.Markdown
import Universum
import CMarkGFM (Node (..), NodeType (..), PosInfo (..), commonmarkToNode)
import CMarkGFM (Node (..), NodeType (..), PosInfo (..), commonmarkToNode, optFootnotes)
import Control.Monad.Trans.Writer.CPS (Writer, runWriter, tell)
import Data.Aeson (FromJSON (..), genericParseJSON)
import Data.ByteString.Lazy qualified as BSL
@ -356,7 +356,7 @@ parseFileInfo config fp input
= runWriter
$ flip runReaderT config
$ nodeExtractInfo fp
$ commonmarkToNode [] []
$ commonmarkToNode [optFootnotes] []
$ toStrict input
markdownScanner :: MarkdownConfig -> ScanAction

View File

@ -15,3 +15,5 @@ extra-deps:
- with-utf8-1.0.2.3
- th-utilities-0.2.4.0@sha256:ba19cd8441aa43dbaed40e9055bb5a7cbd7cf9e154f5253c6bf9293af8b1f96b,1869
- firefly-0.2.1.0@sha256:e9d73486464c3e223ec457e02b30ddd5b550fdbf6292b268c64581e2b07d888b,1519
- git: https://github.com/kivikakk/cmark-gfm-hs
commit: 205f820fd3ca0aefde1d4fdbea30a5e593295c3b

View File

@ -5,43 +5,54 @@
packages:
- completed:
pantry-tree:
sha256: fecec01e618890c284e57cb873b8f9531f479562b7cf08497aef097da3ef90ec
size: 385
hackage: pretty-terminal-0.1.0.0@sha256:e9135d86ebb2a8e3aaf5a79088de4628dbd49988388e0fbfc26c5ecb3c399ad9,1638
pantry-tree:
size: 385
sha256: fecec01e618890c284e57cb873b8f9531f479562b7cf08497aef097da3ef90ec
original:
hackage: pretty-terminal-0.1.0.0
- completed:
pantry-tree:
sha256: 2154c0f4a11842593586dc1932e233cd8c802994763f7d3ce3e5916be8bc7ee5
size: 220
hackage: roman-numerals-0.5.1.5@sha256:819d04d9d442b24629dd058f6f0b02bd78e9f9ae99538bc44ca448f1cb2b7b01,1208
pantry-tree:
size: 220
sha256: 2154c0f4a11842593586dc1932e233cd8c802994763f7d3ce3e5916be8bc7ee5
original:
hackage: roman-numerals-0.5.1.5
- completed:
pantry-tree:
sha256: 3be938e2612faaab078f77bd8e0def999b6f60fc2adda8d89382b0681b4ba420
size: 1051
hackage: with-utf8-1.0.2.3@sha256:3de710e4aa70856ab0845373bfde4746920fd45b8641bfaa3bd5cd2c200c4704,3051
pantry-tree:
size: 1051
sha256: 3be938e2612faaab078f77bd8e0def999b6f60fc2adda8d89382b0681b4ba420
original:
hackage: with-utf8-1.0.2.3
- completed:
pantry-tree:
sha256: 8c577d112a8398a5542aa4205b2e8a470a66d57590e6606d752d71e75d7425ea
size: 882
hackage: th-utilities-0.2.4.0@sha256:ba19cd8441aa43dbaed40e9055bb5a7cbd7cf9e154f5253c6bf9293af8b1f96b,1869
pantry-tree:
size: 882
sha256: 8c577d112a8398a5542aa4205b2e8a470a66d57590e6606d752d71e75d7425ea
original:
hackage: th-utilities-0.2.4.0@sha256:ba19cd8441aa43dbaed40e9055bb5a7cbd7cf9e154f5253c6bf9293af8b1f96b,1869
- completed:
pantry-tree:
sha256: 51d4bf283e1d9ae37e43cd387b112919e45f2fc088f57cbd33c8bad9b0c179f1
size: 600
hackage: firefly-0.2.1.0@sha256:e9d73486464c3e223ec457e02b30ddd5b550fdbf6292b268c64581e2b07d888b,1519
pantry-tree:
size: 600
sha256: 51d4bf283e1d9ae37e43cd387b112919e45f2fc088f57cbd33c8bad9b0c179f1
original:
hackage: firefly-0.2.1.0@sha256:e9d73486464c3e223ec457e02b30ddd5b550fdbf6292b268c64581e2b07d888b,1519
- completed:
name: cmark-gfm
version: 0.2.4
git: https://github.com/kivikakk/cmark-gfm-hs
pantry-tree:
size: 4769
sha256: 1ee2141bab4f2e6d6a9dc39db629dd95557df91a09bef8084ab63633814c9d81
commit: 205f820fd3ca0aefde1d4fdbea30a5e593295c3b
original:
git: https://github.com/kivikakk/cmark-gfm-hs
commit: 205f820fd3ca0aefde1d4fdbea30a5e593295c3b
snapshots:
- completed:
sha256: ef98d70e4018bf01feb00ccdcd33ab26d056dbb71b38057c78fdd0d1ec671c85
size: 618740
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/13.yaml
sha256: ef98d70e4018bf01feb00ccdcd33ab26d056dbb71b38057c78fdd0d1ec671c85
original: lts-19.13

View File

@ -0,0 +1,8 @@
<!--
- SPDX-FileCopyrightText: 2022 Serokell <https://serokell.io>
-
- SPDX-License-Identifier: MPL-2.0
-->
foo [^bad]
[^bad]: [bad link in footnote](./notExists)

View File

@ -0,0 +1,24 @@
#!/usr/bin/env bats
# SPDX-FileCopyrightText: 2022 Serokell <https://serokell.io>
#
# SPDX-License-Identifier: MPL-2.0
load '../helpers/bats-support/load'
load '../helpers/bats-assert/load'
load '../helpers/bats-file/load'
load '../helpers'
@test "We report broken links inside footnotes" {
to_temp xrefcheck -r broken-link-in-footnote
assert_diff expected.gold
}
@test "We're not treating footnotes as 'shortcut reference links'" {
# See: https://github.com/serokell/xrefcheck/issues/155
run xrefcheck -r one-word-footnote
assert_output --partial "All repository links are valid."
}

View File

@ -0,0 +1,13 @@
=== Invalid references found ===
➥ In file broken-link-in-footnote/file-with-footnote-with-broken-link.md
bad reference (relative) at src:8:9-43:
- text: "bad link in footnote"
- link: ./notExists
- anchor: -
⛀ File does not exist:
broken-link-in-footnote/notExists
Invalid references dumped, 1 in total.

View File

@ -0,0 +1,8 @@
<!--
- SPDX-FileCopyrightText: 2022 Serokell <https://serokell.io>
-
- SPDX-License-Identifier: MPL-2.0
-->
foo [^good]
[^good]: hey_I_am_footnote_not_a_link