Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
why3
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Why3
why3
Commits
069bd159
Commit
069bd159
authored
10 years ago
by
MARCHE Claude
Browse files
Options
Downloads
Patches
Plain Diff
Share also the function which outputs a single char in HTML
parent
50dd5ec3
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/util/pp.ml
+9
-7
9 additions, 7 deletions
src/util/pp.ml
src/util/pp.mli
+1
-0
1 addition, 0 deletions
src/util/pp.mli
src/why3doc/doc_lexer.mll
+6
-39
6 additions, 39 deletions
src/why3doc/doc_lexer.mll
with
16 additions
and
46 deletions
src/util/pp.ml
+
9
−
7
View file @
069bd159
...
...
@@ -205,16 +205,18 @@ let sprintf_wnl p =
wnl
fmt
;
kfprintf
(
fun
fmt
->
Format
.
pp_print_flush
fmt
()
;
Buffer
.
contents
b
)
fmt
p
let
html_char
fmt
c
=
match
c
with
|
'\"'
->
pp_print_string
fmt
"""
|
'\''
->
pp_print_string
fmt
"'"
|
'
<
'
->
pp_print_string
fmt
"<"
|
'
>
'
->
pp_print_string
fmt
">"
|
'
&
'
->
pp_print_string
fmt
"&"
|
c
->
pp_print_char
fmt
c
let
html_string
fmt
s
=
for
i
=
0
to
String
.
length
s
-
1
do
match
String
.
get
s
i
with
|
'\"'
->
pp_print_string
fmt
"""
|
'\''
->
pp_print_string
fmt
"'"
|
'
<
'
->
pp_print_string
fmt
"<"
|
'
>
'
->
pp_print_string
fmt
">"
|
'
&
'
->
pp_print_string
fmt
"&"
|
c
->
pp_print_char
fmt
c
html_char
fmt
(
String
.
get
s
i
)
done
...
...
This diff is collapsed.
Click to expand it.
src/util/pp.mli
+
1
−
0
View file @
069bd159
...
...
@@ -147,6 +147,7 @@ val sprintf :
val
sprintf_wnl
:
(
'
b
,
formatter
,
unit
,
string
)
Pervasives
.
format4
->
'
b
val
html_char
:
Format
.
formatter
->
char
->
unit
val
html_string
:
Format
.
formatter
->
string
->
unit
(** formats the string by escaping special HTML characters
quote, double quote, <, > and & *)
...
...
This diff is collapsed.
Click to expand it.
src/why3doc/doc_lexer.mll
+
6
−
39
View file @
069bd159
...
...
@@ -51,38 +51,6 @@
let
get_loc
lb
=
Loc
.
extract
(
Lexing
.
lexeme_start_p
lb
,
Lexing
.
lexeme_end_p
lb
)
let
html_char
fmt
c
=
pp_print_string
fmt
(
match
c
with
|
'
<
'
->
"<"
|
'
>
'
->
">"
|
'
&
'
->
"&"
|
_
->
assert
false
)
let
html_escape
s
=
let
len
=
ref
0
in
String
.
iter
(
function
'
<
'
|
'
>
'
->
len
:=
!
len
+
4
|
'
&
'
->
len
:=
!
len
+
5
|
_
->
incr
len
)
s
;
let
len'
=
!
len
in
let
len
=
String
.
length
s
in
if
len
=
len'
then
s
else
begin
let
t
=
String
.
create
len'
in
let
j
=
ref
0
in
let
app
u
=
let
l
=
String
.
length
u
in
String
.
blit
u
0
t
!
j
l
;
j
:=
!
j
+
l
in
for
i
=
0
to
len
-
1
do
match
s
.
[
i
]
with
|
'
<
'
->
app
"<"
|
'
>
'
->
app
">"
|
'
&
'
->
app
"&"
|
c
->
t
.
[
!
j
]
<-
c
;
incr
j
done
;
t
end
let
pp_html_escape
=
Pp
.
html_string
let
current_file
=
ref
""
let
print_ident
fmt
lexbuf
s
=
...
...
@@ -94,15 +62,14 @@
let
(* f,l,c as *)
loc
=
get_loc
lexbuf
in
(* Format.eprintf " IDENT %s/%d/%d@." f l c; *)
(* is this a def point? *)
let
s
=
html_escape
s
in
try
match
Glob
.
find
loc
with
|
id
,
Glob
.
Def
->
fprintf
fmt
"<a name=
\"
%a
\"
>%a</a>"
Doc_def
.
pp_anchor
id
pp_
html_
escape
s
Doc_def
.
pp_anchor
id
Pp
.
html_
string
s
|
id
,
Glob
.
Use
->
fprintf
fmt
"<a href=
\"
%a
\"
>%a</a>"
Doc_def
.
pp_locate
id
pp_
html_
escape
s
Doc_def
.
pp_locate
id
Pp
.
html_
string
s
with
Not_found
->
(* otherwise, just print it *)
pp_print_string
fmt
s
...
...
@@ -135,7 +102,7 @@ let operator =
let
space
=
[
'
'
'\t'
]
let
ident
=
[
'
A'
-
'
Z'
'
a'
-
'
z'
'
_'
]
[
'
A'
-
'
Z'
'
a'
-
'
z'
'
0
'
-
'
9
'
'
_'
]
*
|
operator
let
special
=
[
'
<
'
'
>
'
'
&
'
]
let
special
=
[
'\''
'
"'
'<' '>' '&']
rule scan fmt empty = parse
| "
(
*
)
" as s
...
...
@@ -212,7 +179,7 @@ and comment fmt do_output = parse
string fmt do_output lexbuf;
comment fmt do_output lexbuf }
| special as c
{ if do_output then html_char fmt c;
{ if do_output then
Pp.
html_char fmt c;
comment fmt do_output lexbuf }
| "'\"'"
| _ as s { if do_output then pp_print_string fmt s;
...
...
@@ -224,7 +191,7 @@ and string fmt do_output = parse
string fmt do_output lexbuf }
| '"' { if do_output then pp_print_string fmt """ }
| special as c
{
if
do_output
then
html_char
fmt
c
;
{ if do_output then
Pp.
html_char fmt c;
string fmt do_output lexbuf }
| "\\" _
| _ as s { if do_output then pp_print_string fmt s;
...
...
@@ -274,7 +241,7 @@ and doc fmt block headings = parse
doc fmt block headings lexbuf }
| special as c
{ if not block then pp_print_string fmt "<p>";
html_char
fmt
c
;
Pp.
html_char fmt c;
doc fmt true headings lexbuf }
| _ as c { if not block then pp_print_string fmt "<p>";
pp_print_char fmt c;
...
...
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