-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
815b1fb
commit 1bf2f90
Showing
6 changed files
with
56 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
\page faq FAQ | ||
\tableofcontents | ||
|
||
\section faq-1 Why doesn't `scn::scan(input, "{},{}")` work? | ||
|
||
The format string given to `scn::scan` is not a pattern, or a regular expression. | ||
Instead, not unlike `std::scanf`, the format string is evaluated left-to-right, | ||
and each replacement field (`{}`) is scanned based on the rules given | ||
by the type to be scanned, and the options inside the replacement field. | ||
|
||
For example, `scn::scan<std::string, std::string>(input, "{},{}")` means: | ||
1. scan a `string` with default options (empty replacement field `{}`), | ||
which means to scan until whitespace | ||
2. scan a literal <code>','</code> character, and discard it | ||
3. scan another `string`, again with default options | ||
|
||
Compare this with a call to `scanf`, with the same behavior | ||
(discounting buffer overflow prevention): | ||
`std::sscanf(input, "%s,%s", output1, output2)`. | ||
|
||
To reiterate, | ||
the way values are scanned is only influenced by the type of the value to be scanned, | ||
and the options given in the replacement field (inside the `{}`). | ||
The context around the replacement field in the format string is not considered. | ||
|
||
To scan until a <code>','</code>, one can do: | ||
`scn::scan<std::string, std::string>("{:[^,]},{}")`. | ||
The `[^,]` in the formatting options for the first argument modifies the scanning behavior to | ||
accept all characters except <code>','</code>. Thus, it won't read until whitespace, | ||
but until a comma, after which the comma is consumed with the literal <code>','</code> in the format string. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
|
||
$(document).ready(function() { | ||
// Find all `<li>` elements inside `#poxy-toc` | ||
$('#poxy-toc').find('ul').children('li') | ||
// Additionally, find all headers | ||
.add('h1, h2, h3, h4, h5') | ||
// Replace: | ||
// - <code>...</code> -> <code>...</code> | ||
// - likewise for <tt> (replace with <code>, too) | ||
.each(function () { | ||
$(this).html($(this).html() | ||
.replace(/<code>(.*?)<\/code>/, '<code>$1</code>') | ||
.replace(/<tt>(.*?)<\/tt>/, '<code>$1</code>')); | ||
}); | ||
}); |