fork(2) download
  1. import sys
  2.  
  3. # on Python 3.5
  4.  
  5. '''
  6. v0.3 Apr. 25, 2018
  7. - conv_super_pre_notation() takes cpp notation
  8. v0.2 Apr. 25, 2018
  9. - add conv_super_pre_notation()
  10. - add conv_sublist()
  11. v0.1 Apr. 24, 2018
  12. - sub list is converted to Markdown style
  13. '''
  14.  
  15.  
  16. def conv_sublist(astr):
  17. if "---" in astr:
  18. astr = astr.replace("---", SPACE4 + SPACE4 + "-")
  19. if "--" in astr:
  20. astr = astr.replace("--", SPACE4 + "-")
  21. return astr
  22.  
  23.  
  24. def conv_super_pre_notation(astr):
  25. astr = astr.replace(">||", "```")
  26. astr = astr.replace(">|cpp|", "```cpp")
  27. astr = astr.replace(">|c|", "```c")
  28. astr = astr.replace("||<", "```")
  29. return astr
  30.  
  31. # read from stdin
  32. lines = sys.stdin.readlines()
  33.  
  34. SPACE4 = " "
  35.  
  36. for elem in lines:
  37. wrk = conv_sublist(elem)
  38. wrk = conv_super_pre_notation(wrk)
  39. print(wrk, end='')
  40.  
Success #stdin #stdout 0.03s 9368KB
stdin
>|cpp|
int
set_block(int fd, int flag)
{
    int flags;

    //
}
||<
stdout
```cpp
int
set_block(int fd, int flag)
{
    int flags;

    //
}
```