Markdown code blocks migration part 7 (#20547)

This commit is contained in:
Andrey Makarov 2022-10-12 17:13:43 +03:00 • committed by GitHub
commit 19ff746916
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 426 additions and 411 deletions

View file

@ -9,25 +9,25 @@
## This module implements helper procs for CGI applications. Example:
##
## .. code-block:: Nim
## ```Nim
## import std/[strtabs, cgi]
##
## import std/[strtabs, cgi]
##
## # Fill the values when debugging:
## when debug:
## setTestData("name", "Klaus", "password", "123456")
## # read the data into `myData`
## var myData = readData()
## # check that the data's variable names are "name" or "password"
## validateData(myData, "name", "password")
## # start generating content:
## writeContentType()
## # generate content:
## write(stdout, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n")
## write(stdout, "<html><head><title>Test</title></head><body>\n")
## writeLine(stdout, "your name: " & myData["name"])
## writeLine(stdout, "your password: " & myData["password"])
## writeLine(stdout, "</body></html>")
## # Fill the values when debugging:
## when debug:
## setTestData("name", "Klaus", "password", "123456")
## # read the data into `myData`
## var myData = readData()
## # check that the data's variable names are "name" or "password"
## validateData(myData, "name", "password")
## # start generating content:
## writeContentType()
## # generate content:
## write(stdout, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n")
## write(stdout, "<html><head><title>Test</title></head><body>\n")
## writeLine(stdout, "your name: " & myData["name"])
## writeLine(stdout, "your password: " & myData["password"])
## writeLine(stdout, "</body></html>")
## ```
import strutils, os, strtabs, cookies, uri
export uri.encodeUrl, uri.decodeUrl
@ -252,9 +252,9 @@ proc setTestData*(keysvalues: varargs[string]) =
## Fills the appropriate environment variables to test your CGI application.
## This can only simulate the 'GET' request method. `keysvalues` should
## provide embedded (name, value)-pairs. Example:
##
## .. code-block:: Nim
## setTestData("name", "Hanz", "password", "12345")
## ```Nim
## setTestData("name", "Hanz", "password", "12345")
## ```
putEnv("REQUEST_METHOD", "GET")
var i = 0
var query = ""
@ -269,9 +269,9 @@ proc setTestData*(keysvalues: varargs[string]) =
proc writeContentType*() =
## Calls this before starting to send your HTML data to `stdout`. This
## implements this part of the CGI protocol:
##
## .. code-block:: Nim
## write(stdout, "Content-type: text/html\n\n")
## ```Nim
## write(stdout, "Content-type: text/html\n\n")
## ```
write(stdout, "Content-type: text/html\n\n")
proc resetForStacktrace() =