Skip to content

Commit aae959a

Browse files
ZJUGuoShuaitatetian
authored andcommitted
add \INPUT & \OUTPUT (alternatives to \REQUIRE & \ENSURE)
1 parent 87fbfe4 commit aae959a

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ Commands for typesetting algorithms must be enclosed in an `algorithmic` environ
110110
\REQUIRE <text>
111111
# A postcondition is optional
112112
\ENSURE <text>
113+
# An input is optional
114+
\INPUT <text>
115+
# An output is optional
116+
\OUTPUT <text>
113117
# The body of your code is a <block>
114118
\STATE ...
115119
\end{algorithmic}

src/Parser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ Parser.prototype._parseRepeat = function() {
353353
return repeatNode;
354354
};
355355

356-
var INPUTS_OUTPUTS_COMMANDS = ['ensure', 'require'];
356+
var INPUTS_OUTPUTS_COMMANDS = ['ensure', 'require', 'input', 'output'];
357357
var STATEMENT_COMMANDS = ['state', 'print', 'return'];
358358
Parser.prototype._parseCommand = function(acceptCommands) {
359359
if (!this._lexer.accept('func', acceptCommands)) return null;

src/Renderer.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,8 @@ Renderer.prototype._buildTree = function(node) {
770770
'state': '',
771771
'ensure': 'Ensure: ',
772772
'require': 'Require: ',
773+
'input': 'Input: ',
774+
'output': 'Output: ',
773775
'print': 'print ',
774776
'return': 'return ',
775777
}[cmdName];

static/samples.html.template

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
\begin{algorithm}
2020
\caption{Test text-style}
2121
\begin{algorithmic}
22+
\REQUIRE some preconditions
23+
\ENSURE some postconditions
24+
\INPUT some inputs
25+
\OUTPUT some outputs
2226
\PROCEDURE{Test-Declarations}{}
2327
\STATE font families: {\sffamily sffamily, \ttfamily ttfamily, \normalfont normalfont, \rmfamily rmfamily.}
2428
\STATE font weights: {normal weight, \bfseries bold, \mdseries

0 commit comments

Comments
 (0)