j178 / leetgo

Best LeetCode friend for geek. :snowboarder:
MIT License
540 stars 32 forks source link

[Bug] Question description is not converted from html to markdown #208

Closed atamanovskii closed 1 year ago

atamanovskii commented 1 year ago

Verify steps

leetgo debug

Leetgo version info  :

1.3.3
commit: dce50922b3858aa1af51871740b6ca3baed439fd
built at: 2023-06-26T10:03:42Z
goos: darwin
goarch: amd64

Project configuration:

No project config file found

Full configuration   :
```yaml
author: Boris Atamanovskii
language: en
code:
  lang: go
  filename_template: '{{ .Id | padWithZero 4 }}{{ if .SlugIsMeaningful }}.{{ .Slug }}{{ end }}'
  separate_description_file: true
  modifiers:
    - name: removeUselessComments
  go:
    out_dir: go
    modifiers:
      - name: removeUselessComments
      - name: changeReceiverName
      - name: addNamedReturn
      - name: addMod
  python3:
    out_dir: python
    executable: python3
  cpp:
    out_dir: cpp
    cxx: g++
    cxxflags: -O2 -std=c++17
  rust:
    out_dir: rust
  java:
    out_dir: java
leetcode:
  site: https://leetcode.com
  credentials:
    from: cookies
    browsers: []
contest:
  out_dir: contest
  filename_template: '{{ .ContestShortSlug }}/{{ .Id }}{{ if .SlugIsMeaningful }}.{{ .Slug }}{{ end }}'
  open_in_browser: true
editor:
  use: code
  command: ""
  args: ""

### Debug log

```shell
2023/07/23 15:50:28 DEBU response url=https://leetcode.com/graphql code=200
  headers=
  │ Cf-Cache-Status: DYNAMIC\r
  │ Cf-Ray: 7eb61bf51cd31fe9-EZE\r
  │ Content-Encoding: gzip\r
  │ Content-Type: application/json\r
  │ Nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}\r
  │ Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=LVnWsJwUtdnoG9KVuSrUSM6wcNgQtOXYmg%2FGmqWXBkZEHDW5kOmSKYE335TyIkgQYaoJ%2BtUTCz2ehcAGCxLy8b12jChYK2c4kJLvp0aBLWrS3yKdgyeMMXBB4WfIbw%3D%3D"}],"group":"cf-nel"
,"max_age":604800}\r
  │ Server: cloudflare\r
  │ X-Content-Type-Options: nosniff\r
  data="{\"data\":{\"question\":{\"questionId\":\"1\",\"questionFrontendId\":\"1\",\"categoryTitle\":\"Algorithms\",\"title\":\"Two Sum\",\"titleSlug\":\"two-sum\",\"content\":\"<p>Given an array of integers <code>nums</code>&nbsp;and an 
integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>\n\n<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use 
the <em>same</em> element twice.</p>\n\n<p>You can return the answer in any order.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\\"example\\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> nums = [2,7,11,15], target = 9\n<strong>Outp
ut:</strong> [0,1]\n<strong>Explanation:</strong> Because nums[0] + nums[1] == 9, we return [0, 1].\n</pre>\n\n<p><strong class=\\"example\\">Example 2:</strong></p>\n\n<pre>\n<strong>Input:</strong> nums = [3,2,4], target = 6\n<strong>Ou
tput:</strong> [1,2]\n</pre>\n\n<p><strong class=\\"example\\">Example 3:</strong></p>\n\n<pre>\n<strong>Input:</strong> nums = [3,3], target = 6\n<strong>Output:</strong> [0,1]\n</pre>\n\n<p>&nbsp;</p>\n<p><strong>Constraints:</strong></
p>\n\n<ul>\n\t<li><code>2 &lt;= nums.length &lt;= 10<sup>4</sup></code></li>\n\t<li><code>-10<sup>9</sup> &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>\n\t<li><code>-10<sup>9</sup> &lt;= target &lt;= 10<sup>9</sup></code></li>\n\t<li><st
rong>Only one valid answer exists.</strong></li>\n</ul>\n\n<p>&nbsp;</p>\n<strong>Follow-up:&nbsp;</strong>Can you come up with an algorithm that is less than&nbsp;<code>O(n<sup>2</sup>)&nbsp;</code>time complexity?\",\"isPaidOnly\":false
,\"translatedTitle\":null,\"translatedContent\":null,\"difficulty\":\"Easy\",\"status\":\"ac\",\"stats\":\"{\\"totalAccepted\\": \\"10.2M\\", \\"totalSubmission\\": \\"20.3M\\", \\"totalAcceptedRaw\\": 10222302, \\"totalSubmissionRaw\\": 
20339062, \\"acRate\\": \\"50.3%\\"}\",\"hints\":[\"A really brute force way would be to search for all possible pairs of numbers but that would be too slow. Again, it's best to try out brute force solutions for just for completeness. It 
is from these brute force solutions that you can come up with optimizations.\",\"So, if we fix one of the numbers, say <code>x</code>, we have to scan the entire array to find the next number <code>y</code> which is <code>value - x</code>
 where value is the input parameter. Can we change our array somehow so that this search becomes faster?\",\"The second train of thought is, without changing the array, can we use additional space somehow? Like maybe a hash map to speed u
p the search?\"],\"similarQuestions\":\"[{\\"title\\": \\"3Sum\\", \\"titleSlug\\": \\"3sum\\", \\"difficulty\\": \\"Medium\\", \\"translatedTitle\\": null}, {\\"title\\": \\"4Sum\\", \\"titleSlug\\": \\"4sum\\", \\"difficulty\\": \\"Medi
um\\", \\"translatedTitle\\": null}, {\\"title\\": \\"Two Sum II - Input Array Is Sorted\\", \\"titleSlug\\": \\"two-sum-ii-input-array-is-sorted\\", \\"difficulty\\": \\"Medium\\", \\"translatedTitle\\": null}, {\\"title\\": \\"Two Sum I
II - Data structure design\\", \\"titleSlug\\": \\"two-sum-iii-data-structure-design\\", \\"difficulty\\": \\"Easy\\", \\"translatedTitle\\": null}, {\\"title\\": \\"Subarray Sum Equals K\\", \\"titleSlug\\": \\"subarray-sum-equals-k\\", 
\\"difficulty\\": \\"Medium\\", \\"translatedTitle\\": null}, {\\"title\\": \\"Two Sum IV - Input is a BST\\", \\"titleSlug\\": \\"two-sum-iv-input-is-a-bst\\", \\"difficulty\\": \\"Easy\\", \\"translatedTitle\\": null}, {\\"title\\": \\"
Two Sum Less Than K\\", \\"titleSlug\\": \\"two-sum-less-than-k\\", \\"difficulty\\": \\"Easy\\", \\"translatedTitle\\": null}, {\\"title\\": \\"Max Number of K-Sum Pairs\\", \\"titleSlug\\": \\"max-number-of-k-sum-pairs\\", \\"difficulty
\\": \\"Medium\\", \\"translatedTitle\\": null}, {\\"title\\": \\"Count Good Meals\\", \\"titleSlug\\": \\"count-good-meals\\", \\"difficulty\\": \\"Medium\\", \\"translatedTitle\\": null}, {\\"title\\": \\"Count Number of Pairs With Abso
lute Difference K\\", \\"titleSlug\\": \\"count-number-of-pairs-with-absolute-difference-k\\", \\"difficulty\\": \\"Easy\\", \\"translatedTitle\\": null}, {\\"title\\": \\"Number of Pairs of Strings With Concatenation Equal to Target\\", 
\\"titleSlug\\": \\"number-of-pairs-of-strings-with-concatenation-equal-to-target\\", \\"difficulty\\": \\"Medium\\", \\"translatedTitle\\": null}, {\\"title\\": \\"Find All K-Distant Indices in an Array\\", \\"titleSlug\\": \\"find-all-k
-distant-indices-in-an-array\\", \\"difficulty\\": \\"Easy\\", \\"translatedTitle\\": null}, {\\"title\\": \\"First Letter to Appear Twice\\", \\"titleSlug\\": \\"first-letter-to-appear-twice\\", \\"difficulty\\": \\"Easy\\", \\"translate
dTitle\\": null}, {\\"title\\": \\"Number of Excellent Pairs\\", \\"titleSlug\\": \\"number-of-excellent-pairs\\", \\"difficulty\\": \\"Hard\\", \\"translatedTitle\\": null}, {\\"title\\": \\"Number of Arithmetic Triplets\\", \\"titleSlug
\\": \\"number-of-arithmetic-triplets\\", \\"difficulty\\": \\"Easy\\", \\"translatedTitle\\": null}, {\\"title\\": \\"Node With Highest Edge Score\\", \\"titleSlug\\": \\"node-with-highest-edge-score\\", \\"difficulty\\": \\"Medium\\", \
\"translatedTitle\\": null}, {\\"title\\": \\"Check Distances Between Same Letters\\", \\"titleSlug\\": \\"check-distances-between-same-letters\\", \\"difficulty\\": \\"Easy\\", \\"translatedTitle\\": null}, {\\"title\\": \\"Find Subarray
s With Equal Sum\\", \\"titleSlug\\": \\"find-subarrays-with-equal-sum\\", \\"difficulty\\": \\"Easy\\", \\"translatedTitle\\": null}, {\\"title\\": \\"Largest Positive Integer That Exists With Its Negative\\", \\"titleSlug\\": \\"largest
-positive-integer-that-exists-with-its-negative\\", \\"difficulty\\": \\"Easy\\", \\"translatedTitle\\": null}, {\\"title\\": \\"Number of Distinct Averages\\", \\"titleSlug\\": \\"number-of-distinct-averages\\", \\"difficulty\\": \\"Easy
\\", \\"translatedTitle\\": null}]\",\"sampleTestCase\":\"[2,7,11,15]\n9\",\"exampleTestcases\":\"[2,7,11,15]\n9\n[3,2,4]\n6\n[3,3]\n6\",\"exampleTestcaseList\":[\"[2,7,11,15]\n9\",\"[3,2,4]\n6\",\"[3,3]\n6\"],\"metaData\":\"{\n  \\"name\
\": \\"twoSum\\",\n  \\"params\\": [\n    {\n      \\"name\\": \\"nums\\",\n      \\"type\\": \\"integer[]\\"\n    },\n    {\n      \\"name\\": \\"target\\",\n      \\"type\\": \\"integer\\"\n    }\n  ],\n  \\"return\\": {\n    \\"type\\"
: \\"integer[]\\",\n    \\"size\\": 2\n  },\n  \\"manual\\": false\n}\",\"codeSnippets\":[{\"lang\":\"C++\",\"langSlug\":\"cpp\",\"code\":\"class Solution {\npublic:\n    vector<int> twoSum(vector<int>& nums, int target) {\n        \n    
}\n};\"},{\"lang\":\"Java\",\"langSlug\":\"java\",\"code\":\"class Solution {\n    public int[] twoSum(int[] nums, int target) {\n        \n    }\n}\"},{\"lang\":\"Python\",\"langSlug\":\"python\",\"code\":\"class Solution(object):\n    d
ef twoSum(self, nums, target):\n        \\"\\"\\"\n        :type nums: List[int]\n        :type target: int\n        :rtype: List[int]\n        \\"\\"\\"\n        \"},{\"lang\":\"Python3\",\"langSlug\":\"python3\",\"code\":\"class Solutio
n:\n    def twoSum(self, nums: List[int], target: int) -> List[int]:\n        \"},{\"lang\":\"C\",\"langSlug\":\"c\",\"code\":\"/**\n * Note: The returned array must be malloced, assume caller calls free().\n */\nint* twoSum(int* nums, in
t numsSize, int target, int* returnSize){\n\n}\"},{\"lang\":\"C#\",\"langSlug\":\"csharp\",\"code\":\"public class Solution {\n    public int[] TwoSum(int[] nums, int target) {\n        \n    }\n}\"},{\"lang\":\"JavaScript\",\"langSlug\":
\"javascript\",\"code\":\"/**\n * @param {number[]} nums\n * @param {number} target\n * @return {number[]}\n */\nvar twoSum = function(nums, target) {\n    \n};\"},{\"lang\":\"Ruby\",\"langSlug\":\"ruby\",\"code\":\"# @param {Integer[]} n
ums\n# @param {Integer} target\n# @return {Integer[]}\ndef two_sum(nums, target)\n    \nend\"},{\"lang\":\"Swift\",\"langSlug\":\"swift\",\"code\":\"class Solution {\n    func twoSum(_ nums: [Int], _ target: Int) -> [Int] {\n        \n   
 }\n}\"},{\"lang\":\"Go\",\"langSlug\":\"golang\",\"code\":\"func twoSum(nums []int, target int) []int {\n    \n}\"},{\"lang\":\"Scala\",\"langSlug\":\"scala\",\"code\":\"object Solution {\n    def twoSum(nums: Array[Int], target: Int): A
rray[Int] = {\n        \n    }\n}\"},{\"lang\":\"Kotlin\",\"langSlug\":\"kotlin\",\"code\":\"class Solution {\n    fun twoSum(nums: IntArray, target: Int): IntArray {\n        \n    }\n}\"},{\"lang\":\"Rust\",\"langSlug\":\"rust\",\"code\
":\"impl Solution {\n    pub fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32> {\n        \n    }\n}\"},{\"lang\":\"PHP\",\"langSlug\":\"php\",\"code\":\"class Solution {\n\n    /**\n     * @param Integer[] $nums\n     * @param Integer 
$target\n     * @return Integer[]\n     */\n    function twoSum($nums, $target) {\n        \n    }\n}\"},{\"lang\":\"TypeScript\",\"langSlug\":\"typescript\",\"code\":\"function twoSum(nums: number[], target: number): number[] {\n\n};\"},
{\"lang\":\"Racket\",\"langSlug\":\"racket\",\"code\":\"(define/contract (two-sum nums target)\n  (-> (listof exact-integer?) exact-integer? (listof exact-integer?))\n\n  )\"},{\"lang\":\"Erlang\",\"langSlug\":\"erlang\",\"code\":\"-spec 
two_sum(Nums :: [integer()], Target :: integer()) -> [integer()].\ntwo_sum(Nums, Target) ->\n  .\"},{\"lang\":\"Elixir\",\"langSlug\":\"elixir\",\"code\":\"defmodule Solution do\n  @spec two_sum(nums :: [integer], target :: integer) :: [i
nteger]\n  def two_sum(nums, target) do\n\n  end\nend\"},{\"lang\":\"Dart\",\"langSlug\":\"dart\",\"code\":\"class Solution {\n  List<int> twoSum(List<int> nums, int target) {\n\n  }\n}\"}],\"topicTags\":[{\"name\":\"Array\",\"slug\":\"ar
ray\",\"translatedName\":null},{\"name\":\"Hash Table\",\"slug\":\"hash-table\",\"translatedName\":null}]}}}"

Description

Question description is not converted to markdown. I guess because of this line. https://github.com/j178/leetgo/blob/8a8c2c62a58bdf5217a9ca18d28f6b7da60d1a93/leetcode/question.go#L429C1-L429C1

However, questions that i pick on leetcode.com do not have an "editorType" field as you can see in the relevant part of the debug log, so they are never converted to markdown.

j178 commented 1 year ago

Thanks for the report! should be fixed in v1.3.4