Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pseudocode-js
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Jeffrey Phillips Freeman
pseudocode-js
Commits
1c0b0db3
There was an error fetching the commit references. Please try again later.
Commit
1c0b0db3
authored
10 years ago
by
Tate, Hongliang Tian
Browse files
Options
Downloads
Patches
Plain Diff
Improve line number support
parent
68339aae
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
PseudoCode.js
+12
-6
12 additions, 6 deletions
PseudoCode.js
static.html
+23
-24
23 additions, 24 deletions
static.html
with
35 additions
and
30 deletions
PseudoCode.js
+
12
−
6
View file @
1c0b0db3
...
...
@@ -577,16 +577,17 @@ Builder.prototype._beginLine = function() {
this
.
_numLOC
++
;
}
var
indent
=
this
.
_blockLevel
*
this
.
_options
.
indentSize
;
this
.
_body
.
push
(
'
<p class="
'
+
className
+
'
" style="padding-left:
'
+
indent
+
'
em;"">
'
);
this
.
_body
.
push
(
'
<p class="
'
+
className
+
'
">
'
);
if
(
this
.
_options
.
lineNumber
&&
this
.
_blockLevel
>
0
)
{
this
.
_body
.
push
(
'
<span class="ps-linenum">
'
+
this
.
_numLOC
+
this
.
_options
.
lineNumberPunc
+
'
</span>
'
);
}
this
.
_body
.
push
(
'
<span class="ps-line-content" style="padding-left:
'
+
indent
+
'
em;">
'
);
}
Builder
.
prototype
.
_endLine
=
function
()
{
this
.
_body
.
push
(
'
</span>
'
)
this
.
_body
.
push
(
'
</p>
'
);
}
...
...
@@ -621,9 +622,8 @@ Builder.prototype._buildTree = function(node) {
this
.
_captionCount
++
;
}
// Then, build the header for algorithm
var
className
=
'
ps-alg
'
;
var
className
=
'
ps-alg
orithm
'
;
if
(
lastCaptionNode
)
className
+=
'
with-caption
'
;
if
(
this
.
_options
.
lineNumber
)
className
+=
'
with-linenum
'
;
this
.
_beginDiv
(
className
);
if
(
lastCaptionNode
)
this
.
_buildTree
(
lastCaptionNode
);
// Then, build other nodes
...
...
@@ -643,8 +643,14 @@ Builder.prototype._buildTree = function(node) {
this
.
_endLine
();
break
;
case
'
algorithmic
'
:
if
(
this
.
_options
.
lineNumber
)
this
.
_numLOC
=
0
;
var
className
=
'
ps-algorithmic
'
;
if
(
this
.
_options
.
lineNumber
)
{
className
+=
'
with-linenum
'
;
this
.
_numLOC
=
0
;
}
this
.
_beginDiv
(
className
);
this
.
_buildTreeForAllChildren
(
node
);
this
.
_endDiv
();
break
;
case
'
block
'
:
// node: <block>
...
...
This diff is collapsed.
Click to expand it.
static.html
+
23
−
24
View file @
1c0b0db3
...
...
@@ -13,37 +13,28 @@
font-weight
:
100
;
-webkit-font-smoothing
:
antialiased
!important
;
}
.pseudo
.ps-alg
{
.pseudo
.ps-alg
orithm
{
margin
:
0.8em
0
;
padding-bottom
:
0.2em
;
/* algorithm environment has borders; algorithmic has not */
border-top
:
3px
solid
black
;
border-bottom
:
2px
solid
black
;
padding-bottom
:
0.2em
;
}
.pseudo
.ps-alg.with-linenum
>
.ps-line.ps-code
{
margin-left
:
0.8em
;
}
.pseudo
.ps-alg.with-caption
>
.ps-line
:first-child
{
.pseudo
.ps-alg
orithm
.with-caption
>
.ps-line
:first-child
{
border-bottom
:
2px
solid
black
;
}
.pseudo
.ps-line
{
line-height
:
1.2
;
margin
:
0
0
;
position
:
relative
;
margin
:
0
;
padding
:
0
;
}
.pseudo
.ps-line
>
span
{
font-size
:
1.21em
;
/* line-content is where indent is added to */
.pseudo
.ps-line-content
{
line-height
:
1.452
;
}
.pseudo
.ps-line
>
.ps-linenum
{
font-size
:
0.8em
;
line-height
:
1em
;
position
:
absolute
;
left
:
0
;
top
:
0.6em
;
display
:
block
;
width
:
1.5em
;
text-align
:
right
;
margin-left
:
-0.5em
;
.pseudo
.ps-line-content
>
span
{
font-size
:
1.21em
;
line-height
:
1.2
;
}
/* keyword */
.pseudo
.ps-keyword
{
font-weight
:
700
;
margin
:
0
0.25em
;
...
...
@@ -51,6 +42,17 @@
.pseudo
.ps-keyword
:first-child
{
margin
:
0
0.25em
0
0
;
}
/* line number support */
.pseudo
.ps-linenum
{
font-size
:
0.8em
;
line-height
:
1em
;
width
:
2em
;
text-align
:
right
;
display
:
inline-block
;
}
.pseudo
.ps-algorithmic.with-linenum
.ps-line.ps-code
.ps-line-content
{
margin-left
:
-1em
;
}
</style>
</head>
<body>
...
...
@@ -145,7 +147,6 @@
\ENDWHILE
\end{algorithmic}
\end{algorithm}
\begin{algorithm}
\begin{algorithmic}
\REQUIRE this is shit!
\ENSURE i think so
...
...
@@ -158,8 +159,6 @@
\
ENDIF
\
ENDWHILE
\
end
{
algorithmic
}
\
caption
{
this
is
it
!}
\
end
{
algorithm
}
</
pre
>
<script
type=
"text/javascript"
>
var
code
=
document
.
getElementById
(
"
code
"
).
textContent
;
...
...
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