TestMdRender.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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';
  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['term'] = <<<md
  38. ## heading
  39. [[bhagavantu]]
  40. ```
  41. test
  42. ```
  43. md;
  44. $data['noteMulti'] = <<<md
  45. ## heading
  46. [点击](http://127.0.0.1:3000/my/article/para/168-876?mode=edit&channel=00ae2c48-c204-4082-ae79-79ba2740d506&book=168&par=876)
  47. ----
  48. dfef
  49. ```
  50. bla **content**
  51. {{99-556-8-12}}
  52. bla **content**
  53. ```
  54. md;
  55. $data['note'] = '`bla bla`';
  56. $data['noteTpl'] = <<<md
  57. {{note|trigger=kacayana|text={{99-556-8-12}}}}
  58. md;
  59. $data['trigger'] = <<<md
  60. ## heading
  61. ddd
  62. - title
  63. content-1
  64. - title-2
  65. content-2
  66. aaa bbb
  67. md;
  68. $data['exercise'] = <<<md
  69. {{168-916-10-37}}
  70. {{exercise|1|((168-916-10-37))}}
  71. {{exercise|
  72. id=1|
  73. content={{168-916-10-37}}
  74. }}
  75. {{exercise|
  76. id=2|
  77. content=# ddd}}
  78. md;
  79. $data['article'] = <<<md
  80. {{article|
  81. type=article|
  82. id=27ade9ad-2d0c-4f66-b857-e9335252cc08|
  83. title=第一章 戒律概说(Vinaya)|
  84. style=modal}}
  85. md;
  86. //$wiki = MdRender::markdown2wiki($data['noteMulti']);
  87. //$xml = MdRender::wiki2xml($wiki,['00ae2c48-c204-4082-ae79-79ba2740d506']);
  88. //$this->info($xml);
  89. //$html = MdRender::markdownToHtml($xml);
  90. //$this->info($html);
  91. //$html = MdRender::xmlQueryId($xml, "1");
  92. //$sent = MdRender::take_sentence($html);
  93. //print_r($sent);
  94. echo MdRender::render2($data['article'],['00ae2c48-c204-4082-ae79-79ba2740d506'],null,'read','translation');
  95. return 0;
  96. }
  97. }