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