Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/nextcloud-config-converter.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-02-08 12:20:38 +0300
committerMorris Jobke <hey@morrisjobke.de>2015-02-08 12:20:38 +0300
commitf14a16d8c327c24df9951eacd5414bd340b48914 (patch)
tree7535a5d7f11652d963e824b13dd04e1ac9b3360d
parent75410b4eaea81badd47f63b88476bd41d7ac7a3d (diff)
escape backslashs in RST - outside of code blocks
-rw-r--r--convert.php24
1 files changed, 23 insertions, 1 deletions
diff --git a/convert.php b/convert.php
index e9531ac..71490af 100644
--- a/convert.php
+++ b/convert.php
@@ -32,6 +32,28 @@
require 'vendor/autoload.php';
+function escapeRST($string) {
+ # just replace all \ by \\ if there is no code block present
+ if(strpos($string, '``') === false) {
+ return str_replace('\\', '\\\\', $string);
+ }
+
+ $parts = explode('``', $string);
+ foreach ($parts as $key => &$part) {
+ # just even parts are outside of the code block
+ # example:
+ #
+ # Test code: ``$my = $code + 5;`` shows that ...
+ #
+ # The code part has the id 1 and is an odd number
+ if($key%2 == 0) {
+ str_replace('\\', '\\\\', $part);
+ }
+ }
+
+ return implode('``', $parts);
+}
+
// tag which invokes to copy a config description to the current position
$COPY_TAG = 'see';
// file which should be parsed
@@ -182,7 +204,7 @@ foreach ($blocks as $block) {
}
$RSTRepresentation .= "\n";
// print description
- $RSTRepresentation .= $phpdoc->getText();
+ $RSTRepresentation .= escapeRST($phpdoc->getText());
// empty line
$RSTRepresentation .= "\n";