Skip to content

Commit 6591354

Browse files
committed
fix for VersoManual.imports
1 parent 8270570 commit 6591354

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/verso-manual/VersoManual/Imports.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ Parses, but does not validate, a module header.
3232
def imports : CodeBlockExpanderOf ImportsParams
3333
| { «show» } , str => do
3434
let p := Parser.whitespace >> Parser.Module.header.fn
35-
let headerStx ← parseStrLitWith p str
35+
-- Provenance of `str` here is from Verso parser
36+
let headerStx ← p.parseString str (versoStyle := true)
3637
let hl ← highlight headerStx #[] {}
3738
if «show» then
3839
``(Block.other (Block.lean $(quote hl) {}) #[Block.code $(quote str.getString)])

src/verso/Verso/Parser.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,8 @@ namespace Verso.Doc.Concrete
985985
open Verso.Parser
986986
open Lean Elab Term
987987

988+
-- Important! Both functions below expect strings in "Lean style",
989+
-- that is to say, with positions including quotes around the string.
988990
public def stringToInlines [Monad m] [MonadError m] [MonadLog m] [MonadOptions m] [MonadEnv m] [MonadQuotation m] (s : StrLit) : m (Array Syntax) :=
989991
withRef s do
990992
return (← textLine.parseString s).getArgs

src/verso/Verso/SyntaxUtils.lean

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,4 +320,11 @@ public def runParserCategory [Monad m] [MonadEnv m] [MonadLog m] [MonadOptions m
320320
(catName : Name) (input : StrLit) (versoStyle : Bool := true) (fileName : Option String := none) : m (Except String Syntax) :=
321321
runParserCategoryGen runParserCategory.toErrorMsg catName input versoStyle fileName
322322

323+
/- This function can be used to check whether string are in Verso
324+
style or in Lean style -/
325+
public def checkString (str : StrLit) : String :=
326+
let s := str.getString
327+
let sz := (str.raw.getTailPos?.getD 0 |>.byteIdx) - str.raw.getPos!.byteIdx
328+
s!"real size: {s.length}, syntax size: {sz}"
329+
323330
end Verso.SyntaxUtils

0 commit comments

Comments
 (0)