Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
teiwa
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alice Brenon
teiwa
Commits
92ca859d
Commit
92ca859d
authored
4 years ago
by
Alice Brenon
Browse files
Options
Downloads
Patches
Plain Diff
Encode punctuation characters with a <pc> instead of <w>
parent
f3fdb961
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/Text/TEIWA/Annotation.hs
+10
-6
10 additions, 6 deletions
lib/Text/TEIWA/Annotation.hs
with
10 additions
and
6 deletions
lib/Text/TEIWA/Annotation.hs
+
10
−
6
View file @
92ca859d
...
...
@@ -10,9 +10,9 @@ module Text.TEIWA.Annotation (
)
where
import
Control.Monad.Except
(
MonadError
(
..
))
import
Control.Monad.RWS
(
RWST
,
evalRWST
,
get
,
put
,
tell
)
import
Data.Text.Lazy
as
Text
(
Text
,
breakOn
,
concat
,
drop
,
length
,
unpack
)
import
Text.TEIWA.Config
(
Config
)
import
Control.Monad.RWS
(
RWST
,
evalRWST
,
get
,
put
,
reader
,
tell
)
import
Data.Text.Lazy
as
Text
(
Text
,
breakOn
,
concat
,
drop
,
head
,
length
,
unpack
)
import
Text.TEIWA.Config
(
Config
(
..
)
)
import
Text.TEIWA.Error
(
Error
(
..
))
type
Attributes
=
[(
Text
,
Text
)]
...
...
@@ -50,11 +50,15 @@ w = token "w"
check
::
MonadError
Error
m
=>
Maybe
Text
->
TokenAnnotation
->
(
Text
,
Text
)
->
Editor
m
check
openingTag
expected
@
(
TokenAnnotation
{
form
})
(
before
,
focused
)
=
let
expectedLength
=
Text
.
length
form
in
if
Text
.
length
focused
>=
expectedLength
then
put
(
Text
.
drop
expectedLength
focused
)
*>
mapM_
tell
[
before
,
maybe
""
id
openingTag
,
w
expected
]
then
do
tagged
<-
reader
(
handle
.
punctuation
)
put
(
Text
.
drop
expectedLength
focused
)
mapM_
tell
[
before
,
maybe
""
id
openingTag
,
tagged
]
else
throwError
(
TermNotFound
$
Text
.
unpack
form
)
where
expectedLength
=
Text
.
length
form
handle
f
=
(
if
expectedLength
==
1
&&
f
(
Text
.
head
form
)
then
pc
else
w
)
expected
tokenLevel
::
MonadError
Error
m
=>
Maybe
Text
->
[
TokenAnnotation
]
->
Editor
m
tokenLevel
Nothing
[]
=
pure
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment