TestMdRender.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. namespace App\Console\Commands;
  3. use Illuminate\Console\Command;
  4. use App\Http\Api\MdRender;
  5. use Illuminate\Support\Str;
  6. class TestMdRender extends Command
  7. {
  8. /**
  9. * The name and signature of the console command.
  10. *
  11. * @var string
  12. */
  13. protected $signature = 'test:md.render {item?}';
  14. /**
  15. * The console command description.
  16. *
  17. * @var string
  18. */
  19. protected $description = 'Command description';
  20. /**
  21. * Create a new command instance.
  22. *
  23. * @return void
  24. */
  25. public function __construct()
  26. {
  27. parent::__construct();
  28. }
  29. /**
  30. * Execute the console command.
  31. *
  32. * @return int
  33. */
  34. public function handle()
  35. {
  36. $data = array();
  37. $data['bold'] = <<<md
  38. 三十**"aa"** **“aa”** 三 **“十位”** **[[十位]]** 经
  39. 在[中间]六处为**[ditthippatta]**,在极果为**慧解脱**
  40. md;
  41. $data['term'] = <<<md
  42. ## heading
  43. [[bhagavantu]]
  44. ```
  45. test
  46. ```
  47. md;
  48. $data['noteMulti'] = <<<md
  49. ## heading
  50. [点击](http://127.0.0.1:3000/my/article/para/168-876?mode=edit&channel=00ae2c48-c204-4082-ae79-79ba2740d506&book=168&par=876)
  51. ----
  52. dfef
  53. ```
  54. bla **content**
  55. {{99-556-8-12}}
  56. bla **content**
  57. ```
  58. md;
  59. $data['note'] = '`bla bla`';
  60. $data['noteTpl'] = <<<md
  61. {{note|trigger=kacayana|text={{99-556-8-12}}}}
  62. md;
  63. $data['trigger'] = <<<md
  64. ## heading
  65. ddd
  66. - title
  67. content-1
  68. - title-2
  69. content-2
  70. aaa bbb
  71. md;
  72. $data['exercise'] = <<<md
  73. {{168-916-10-37}}
  74. {{exercise|1|((168-916-10-37))}}
  75. {{exercise|
  76. id=1|
  77. content={{168-916-10-37}}
  78. }}
  79. {{exercise|
  80. id=2|
  81. content=# ddd}}
  82. md;
  83. $data['article'] = <<<md
  84. {{article|
  85. type=article|
  86. id=27ade9ad-2d0c-4f66-b857-e9335252cc08|
  87. title=第一章 戒律概说(Vinaya)|
  88. style=modal}}
  89. md;
  90. //$wiki = MdRender::markdown2wiki($data['noteMulti']);
  91. //$xml = MdRender::wiki2xml($wiki,['00ae2c48-c204-4082-ae79-79ba2740d506']);
  92. //$this->info($xml);
  93. //$html = MdRender::markdownToHtml($xml);
  94. //$this->info($html);
  95. //$html = MdRender::xmlQueryId($xml, "1");
  96. //$sent = MdRender::take_sentence($html);
  97. //print_r($sent);
  98. foreach ($data as $key => $value) {
  99. $_item = $this->argument('item');
  100. if(!empty($_item) && $key !==$_item){
  101. continue;
  102. }
  103. echo MdRender::render2($value,['00ae2c48-c204-4082-ae79-79ba2740d506'],null,'read','translation');
  104. }
  105. return 0;
  106. }
  107. }