TestMdRender.php 2.7 KB

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