TestMdRender.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. * run php artisan test:md.render term unity
  11. * @var string
  12. */
  13. protected $signature = 'test:md.render {item?} {--format=html}';
  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. **三十位** 经
  39. 在[中间]六处为**[[licchavi]]**,在极果为**慧解脱**
  40. md;
  41. $data['sentence'] = <<<md
  42. {{140-535-2-2}}
  43. md;
  44. $data['link'] = <<<md
  45. aa `[link](wikipali.org/aa.php?view=b&c=d)` bb
  46. md;
  47. $data['term'] = <<<md
  48. ## heading
  49. [[bhagavantu]]
  50. ```
  51. test
  52. ```
  53. md;
  54. $data['noteMulti'] = <<<md
  55. ## heading
  56. [点击](http://127.0.0.1:3000/my/article/para/168-876?mode=edit&channel=00ae2c48-c204-4082-ae79-79ba2740d506&book=168&par=876)
  57. ----
  58. dfef
  59. ```
  60. bla **content**
  61. {{99-556-8-12}}
  62. bla **content**
  63. ```
  64. md;
  65. $data['note'] = '`bla bla`';
  66. $data['noteTpl'] = <<<md
  67. {{note|trigger=kacayana|text={{99-556-8-12}}}}
  68. md;
  69. $data['trigger'] = <<<md
  70. ## heading
  71. ddd
  72. - title
  73. content-1
  74. - title-2
  75. content-2
  76. aaa bbb
  77. md;
  78. $data['exercise'] = <<<md
  79. {{168-916-10-37}}
  80. {{exercise|1|((168-916-10-37))}}
  81. {{exercise|
  82. id=1|
  83. content={{168-916-10-37}}
  84. }}
  85. {{exercise|
  86. id=2|
  87. content=# ddd}}
  88. md;
  89. $data['article'] = <<<md
  90. {{article|
  91. type=article|
  92. id=27ade9ad-2d0c-4f66-b857-e9335252cc08|
  93. title=第一章 戒律概说(Vinaya)|
  94. style=modal}}
  95. md;
  96. //$wiki = MdRender::markdown2wiki($data['noteMulti']);
  97. //$xml = MdRender::wiki2xml($wiki,['00ae2c48-c204-4082-ae79-79ba2740d506']);
  98. //$this->info($xml);
  99. //$html = MdRender::markdownToHtml($xml);
  100. //$this->info($html);
  101. //$html = MdRender::xmlQueryId($xml, "1");
  102. //$sent = MdRender::take_sentence($html);
  103. //print_r($sent);
  104. foreach ($data as $key => $value) {
  105. $_item = $this->argument('item');
  106. if(!empty($_item) && $key !==$_item){
  107. continue;
  108. }
  109. $format = $this->option('format');
  110. echo MdRender::render2($value,
  111. ['00ae2c48-c204-4082-ae79-79ba2740d506'],
  112. null,'read','translation',
  113. $contentType="markdown",$format);
  114. }
  115. return 0;
  116. }
  117. }