DavidEGrayson

David Grayson
19 Snippets
(38th place)
Published
1 Channel
Created
2 Channels
Following
3 points (21463rd place)
Reputation
Top 10% Publisher
Junior Code Generator
Junior Judge
Junior Popular Coder
Junior Autobiographer
Senior Autobiographer
Serious Famous Coder
Senior Famous Coder
Serious Wise Coder
Recent Snippets See all snippets by DavidEGrayson
public by DavidEGrayson 2531 0 3 0
This is a copy of https://meta.discourse.org/t/certain-info-strings-on-fenced-code-blocks-break-formatting-between-the-blocks/42467
This is a copy of https://meta.discourse.org/t/certain-info-strings-on-fenced-code-blocks-break-formatting-between-the-blocks/42467:
discourse_fence_bug.md
I just encountered a bug while I was writing a post on a Discourse-powered forum and would like to report it. It seems like if I have two fenced code blocks with an info string of "{.cpp}", where each block starts with a line equal to "\`\`\`{.cpp}" and ends with a line equal to "\`\`\`", then any text formatting between the two blocks of code does not work at all, and we see the markup instead of seeing nicely-formatted text. See below for an example: ```{.cpp} // Here is a block of C++ code. ``` For some reason we cannot have `monospace`, _italic_, **bold**, or [link](https://example.com) text in this paragraph, which is between two blocks of C++ code. In fact, I can't find any other Markdown, BBCode or HTML that does work in this area. We can't even have multiple paragraphs. ```{.cpp} // Here is a second block of C++ code. ``` A workaround for this is to remove the `{.cpp}` info string on the first code block, but of course that destroys the code highlighting in that first block. I couldn't find any better solution even though I tried info strings of ".cpp", "cpp", and "c++". I made a [copy of this post as a Gist](https://gist.github.com/DavidEGrayson/05e71787bd36139f59088f59101a04a5) so you can see the markup I used and verify that it works correctly in GitHub-flavored Markdown. --David
$ ~/Documents/scraps/test_midipix/perk.exe -Ip yaml /usr/bin/ls.exe | ruby -ryaml -e "p YAML.load(ARGF)" {"msys-intl-8.dll"=>["libintl_bindtextdomain", "libintl_dcgettext", "libintl_gettext", "libintl_setlocale", "libintl_textdomain"], "msys-2.0.dll"=>["__assert_func", "__ctype_ptr__", "__cxa_atexit", "__errno", "__getreent", "__locale_mb_cur_max", "__main", "_dll_crt0", "_exit", "_impure_ptr", "abort", "acl", "btowc", "calloc", "clock_gettime", "closedir", "cygwin_internal", "dirfd", "dll_dllcrt0", "error", "exit", "fclose", "fflush_unlocked", "fprintf", "fputs_unlocked", "free", "fstat", "fwrite", "fwrite_unlocked", "getenv", "getgrgid", "getgrnam", "getopt_long", "getpwnam", "getpwuid", "gettimeofday", "ioctl", "isatty", "iswcntrl", "iswctype", "iswprint", "localeconv", "localtime", "longjmp", "lstat", "malloc", "mbrtowc", "mbsinit", "mbsrtowcs", "mbstowcs", "memchr", "memcmp", "memcpy", "memmove", "mempcpy", "memset", "mktime", "msys_detach_dll", "nl_langinfo", "opendir", "optarg", "optind", "posix_memalign", "printf", "program_invocation_name", "program_invocation_short_name", "putc_unlocked", "raise", "readdir", "readlink", "realloc", "setjmp", "setlocale", "sigaction", "sigaddset", "sigemptyset", "sigismember", "signal", "sigprocmask", "sprintf", "stat", "stpcpy", "stpncpy", "strcasecmp", "strcat", "strchr", "strcmp", "strcoll", "strcpy", "strdup", "strftime", "strlen", "strncmp", "strrchr", "strstr", "strtoul", "strtoumax", "tcgetpgrp", "tolower", "toupper", "towlower", "wcscat", "wcslen", "wcstombs", "wcswidth", "wctype", "wcwidth", "wmemchr", "wmemcpy"], "KERNEL32.dll"=>["GetACP", "GetModuleHandleA", "GetModuleHandleW", "GetProcAddress"]}
$ cat stuff.yaml abc.dll: - tolower - wcslen USER32.dll: - MessageBoxW - stuff $ ruby -ryaml -e "p YAML.load(ARGF)" < stuff.yaml {"abc.dll"=>["tolower", "wcslen"], "USER32.dll"=>["MessageBoxW", "stuff"]}
public by David Grayson 1850 0 3 0
How to check if an a variable is defined as an array in Bash
How to check if an a variable is defined as an array in Bash:
defined_as_array.sh
foo=" hi declare -a foo" bar=(a b) lint_var_defined_as_non_array() { if [[ "${!1+x}" == "" ]]; then return 1 # not defined fi if [[ "$(declare -p $1)" == "declare -a "* ]]; then return 1 # defined as an array fi return 0 } lint_var_defined_as_array() { if [[ "${!1+x}" == "" ]]; then return 1 # not defined fi if [[ "$(declare -p $1)" == "declare -a "* ]]; then return 0 # defined as an array fi return 1 } if lint_var_defined_as_non_array foo; then echo foo is non array fi if lint_var_defined_as_non_array bar; then echo bar is non array fi if lint_var_defined_as_non_array car; then echo car is non array fi if lint_var_defined_as_array foo; then echo foo is array fi if lint_var_defined_as_array bar; then echo bar is array fi if lint_var_defined_as_array car; then echo car is array fi
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 Learning about PGP (°◡°) -----BEGIN PGP SIGNATURE----- iQIcBAEBCgAGBQJWOBJXAAoJEOit7wARLpAOGg8P+wUKkeUUpX8DqmAyMLT0Na9W fOTZndhkj3Os/cda4vBIQq0pCP8oFKz9hFz52hLAp4sGgfo3kD2oaESo8LSqOfGq gsjEhobA2qm0lZlsM4ADD1JHMlSUALB1LCGtkYaGxtKEMjuX9iCU3PqSGdKp/MiZ tx6ph1jOXU7rDrBEAZl4hvS8DufTL40rG8O38RAB/PtiJMWcm64SzOpS+xz+zsKZ 3rreXXmHYgZnxvDpJtNKa72uErEh0yTwJHKKK6GNnLyg1kr3h5SPI1yqJX/Kun+j q2mGL9HUlgYYcITZ6fHo6xlFolOxYi7fO1sQtudY+ld+A95QtuYDS7SkzxvvIXgb BKsoTO7qufaYk9dk2FNy4k/rcRp89Yr3q9QaRit1J2vLysj31sbLulJiXNlsotJg OgtV9VKiHCJeuq9KPdM4pkiVYFf0laOMb/U+Wn3aTT6SESOdJzyiqBjlayQWbsuZ 9E+l5MTurnIwdLGF0djc6KieYpkzDdEjMBAXzo+4K4WmZBt6Vds8ArwlpR2SXgdC JCqrcjlg6c48EdzuHdSqtVTiZVYRhV/uVHLc2aSorC9wOSTmiPEGvvfe/HgWGmVn bGGR3TakSpV0F6AWobFUbew55PybQvyteP9klT3qCq8cMtLC6LfkKFeMe5+P9pSY ZDtm7ABvx+FTAuKFppwm=caqb -----END PGP SIGNATURE-----