Skip to content

Commit

Permalink
Merge pull request #31 from Seasawher/Seasawher/issue30
Browse files Browse the repository at this point in the history
change / add ignore pattern
  • Loading branch information
Seasawher authored Aug 16, 2024
2 parents 1ace0f6 + 1278a2a commit fab4021
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 8 deletions.
11 changes: 10 additions & 1 deletion MkExercise/Extract.lean
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,17 @@ and replace it with `sorry` -/
def extractExercise (lines : List String) : String := Id.run do
let mut listen := true
let mut content := ""
let mut «--##--» := false
for line in lines do
if line.endsWith "--#" then
-- ignore pattern for a line
if line.endsWith "--##" then
continue

-- ignore pattern for a block
if line.trim = "--##--" then
«--##--» := ! «--##--»
continue
if «--##--» then
continue

if let some index := findWhere line "-- sorry" then
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ GitHub Action allows you to run this every time a particular branch is updated,

* Replace the code enclosed by `-- sorry` with `sorry`, preserving indentation.
* Replace the code after `/- sorry -/` with sorry.
* Lines ending with `--#` are ignored.
* Lines ending with `--##` are ignored.
* Blocks enclosed with `--##--` are ignored.

Check the test code for more information.

Expand Down
8 changes: 7 additions & 1 deletion Test/Exp/Solution.lean
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@ example : 1 + n = n + 1 := by
1 + n = n + 1 := by sorry
_ = n + 1 := by sorry

/-- ignore some sentences -/
/-- ignore pattern for a line -/
example : 1 + n = n + 1 := by
calc
1 + n = 1 + n := by rfl
_ = n + 1 := by sorry

/-- ignore pattern for a block -/
example : 1 + n = n + 1 := by
calc
1 + n = 1 + n := by rfl
_ = n + 1 := by ac_rfl
22 changes: 17 additions & 5 deletions Test/Src/Solution.lean
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,24 @@ example : 1 + n = n + 1 := by
1 + n = n + 1 := by /- sorry -/ rw [Nat.add_comm]
_ = n + 1 := by /- sorry -/ rfl

/-- ignore some sentences -/
/-- ignore pattern for a line -/
example : 1 + n = n + 1 := by
calc
1 + n = 1 + n := by rfl
_ = 1 + n := by rfl --#
_ = 1 + n := by rfl --#
_ = 1 + n := by rfl --#
_ = 1 + n := by rfl --#
_ = 1 + n := by rfl --##
_ = 1 + n := by rfl --##
_ = 1 + n := by rfl --##
_ = 1 + n := by rfl --##
_ = n + 1 := by /- sorry -/ rw [Nat.add_comm]

/-- ignore pattern for a block -/
example : 1 + n = n + 1 := by
calc
1 + n = 1 + n := by rfl
--##--
_ = 1 + n := by rfl
_ = 1 + n := by rfl
_ = 1 + n := by rfl
_ = 1 + n := by rfl
--##--
_ = n + 1 := by ac_rfl

0 comments on commit fab4021

Please sign in to comment.