1

I am trying marker.js to highlight the containing word inside brackets given the user query.

For instance, when the user gives a query

"How covid-19 originated?"

and in the answer response:

Coronavirus disease 2019 (COVID‑19) is an infectious disease caused by severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2).

I want the text "COVID-19" inside brackets to be highlighted. The current parameters highlight the COVID-19 occurrences without brackets, but when they are inside brackets, it just don't work.

Here's my current working snippet:

var brands = "where the covid-19 originated?";

var instance = new Mark(document.querySelector("body"));

instance.mark(brands, {
    accuracy: {
      value: "exactly",
      limiters: [".", ",", "(", ")"]
    },
     ignorePunctuation: ":;.,-–—‒_(){}[]!'\"+=?!".split(""),
   wildcards: "enabled",
  separateWordSearch: true,
  acrossElements: true
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/mark.js/7.0.0/mark.min.js"></script>
<body>
  <div>Coronavirus disease 2019 (COVID‑19) is an infectious disease caused by severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2).

It was first identified in December 2019 in Wuhan, Hubei, China, and has resulted in an ongoing pandemic.

As of 23 August 2020, more than 23.1 million cases have been reported across 188 countries and territories, resulting in more than 802,000 deaths.

More than 14.8 million people have recovered.Common symptoms include fever, cough, fatigue, shortness of breath, and loss of smell and taste.

While most people have mild symptoms, some people develop acute respiratory distress syndrome (ARDS) possibly precipitated by cytokine storm, multi-organ failure, septic shock, and blood clots.

The time from exposure to onset of symptoms is typically around five days, but may range from two to fourteen days.The virus is spread primarily via nose and mouth secretions including small droplets produced by coughing, sneezing, and talking.

The droplets usually do not travel through air over long distances.

However, those standing in close proximity may inhale these droplets and become infected.

People may also become infected by touching a contaminated surface and then touching their face.

The transmission may also occur through smaller droplets that are able to stay suspended in the air for longer periods of time in enclosed spaces.

It is most contagious during the first three days after the onset of symptoms, although spread is possible before symptoms appear, and from people who do not show symptoms.

The standard method of diagnosis is by real-time reverse transcription polymerase chain reaction (rRT-PCR) from a nasopharyngeal swab.

Chest CT imaging may also be helpful for diagnosis in individuals where there is a high suspicion of infection based on symptoms and risk factors; however, guidelines do not recommend using CT imaging for routine screening.Recommended measures to prevent infection include frequent hand washing, maintaining physical distance from others (especially from those with symptoms), quarantine (especially for those with symptoms), covering coughs, and keeping unwashed hands away from the face.

The use of cloth face coverings such as a scarf or a bandana has been recommended by health officials in public settings to minimise the risk of transmissions, with some authorities requiring their use.

Health officials also stated that medical-grade face masks, such as N95 masks, should be used only by healthcare workers, first responders, and those who directly care for infected individuals.There are no proven vaccines nor specific antiviral treatments for COVID-19.

Management involves the treatment of symptoms, supportive care, isolation, and experimental measures.

The World Health Organization (WHO) declared the COVID‑19 outbreak a public health emergency of international concern (PHEIC) on 30 January 2020 and a pandemic on 11 March 2020.

Local transmission of the disease has occurred in most countries across all six WHO regions.</div>
</body>
HQuser
  • 640
  • 10
  • 26

0 Answers0